Hexabitz Distance Measurement System

About the project

Build a tiny Distance measurement logger by connecting Hexabitz IR module to Hexabitz Micro SD card module.

Project info

Difficulty: Moderate

Platforms: STMicroelectronics

Estimated time: 1 hour

License: MIT license (MIT)

Items used in this project

Hardware components

Hexabitz Micro SD Memory Card Module (H1BR60) Hexabitz Micro SD Memory Card Module (H1BR60) x 1
Hexabitz Time-of-flight IR Sensor Module (H08R60) Hexabitz Time-of-flight IR Sensor Module (H08R60) x 1


Introduction :

Hexabitz IR ToF (Lidar) Sensor are great tools to measure distance without actual contact and used at several places like Robots, distance measurement etc.

This is an efficient way to measure small distances precisely.

In this project, we have used a Hexabitz IR Sensor to determine the distance of an obstacle from the sensor and Storing the distance data by Micro SD card module.

IR sensors are, for the most part, completely insensitive to hindering factors like: Light, Dust, Smoke, Mist, Vapor, and Lint.

The Micro SD Card module is used for transferring distance data to a standard SD card.



First: Plan the array and assemble the hardware:

· We prepare the project components and plan our array design by aligning modules side-by-side

· Then we solder the modules together using Hexabitz Fixture.

Second: Writing code with Keil uVision

· Check out this article for writing code with Keil uVision


· Fixed topology file:

Inter-array communication in Hexabitz is done using a routing table stored in a special header (.h) file. This header file describes the number of modules and how they are connected to each other as well as other important information for the array; hence, it is called a topology header file. Currently, you need to make a topology file manually (by modifying an existing one and adding the modules number so that they can communicate with each other and know their neighbors.)

Then go to project.h as shown in the photo below and un-comment the header.

· Press on main.c after creating topology

  • You must know that we have two projects one for IR module (H08R6) and the other for micro SD (H1BR6) module.
  • We need to build our files for both projects.
  • BOS offers a powerful remote memory read/write access functionality through specific Messages and APIs.
  • This allows a module to access and modify almost any RAM or Flash memory location in another module in the array, thus, providing powerful synchronization and granular control.

The IR module (H08R6) code:
  • The IR sensor module measures distance, and it always send the distance value to the micro SD module by a memory write API in for loop.

  • First, I define a float variable to storing the measured distance.

  • BOS Variables can be addressed with easy-to-use virtual addresses. We can link a float sensor value to BOS Var 1 by AddBOSvar API and access it from micro SD module in the array.
  • We set sensor units to mm and stream range continuously to a memory variable at 10 Hz.

The micro SD (H1BR6) module code:
  • In (H1BR6) module code we define BOS sensor variable. Using the keyword volatile in front of a variable definition tells the compiler that this variable might change outside the program (by a remote IR module).

  • Data Logs: micro SD memory card module H1BR60 feature permanent logging functionality to a FAT-formatted micro-SD card.
  • You can create up to 10 simultaneous logs with up to 30 different variables across all logs.
  • Logs are tabulated text files that consist of a header section, a bunch of columns-each representing a single logged variable, and a bunch of rows-each representing the variables’ value at a given moment. Logs have two types: RATE and EVENT.
  • The former type logs variable state periodically at a fixed rate, while the latter logs only a state change.
  • We create below a rate-based log and log the sensor value.


  • Logging is then started and stopped after 10 seconds. You can increase this time to logging more sensor data. The indicator LED is used to show some blinks !


If the module booted without a uSD card (or with a malfunctioning one), the logging functionality will be aborted and the indicator LED will blink indefinitely. Just replace the card and the module should resume normal operation.

  • The.txt file named "mylog.txt" was created, and the sensor data were wrote into it.
  • This data is used to plot a graph (with Spyder/python3.7).
  • Profile of the objects that are obstacles has been generated using Hexabitz distance measurement system.
  • We measured the distance of several objects on the x-axis by moving the measurement system horizontally.

  • We measured the distance for an object moving on the y-axis and the measurement system was fixed.


· Robotics:

1- Collision Detection Warning System: Hexabitz IR module allow the mobile robot or vehicle to detect when an obstacle is in front of it and thus avoid crashing into the obstacle.

2- Hexabitz IR module can function as a 1D Lidar in multi object tracking for automotive systems. It can measure distance accurately up to 2m.

3- Low cost solution for 3D mapping of environment using 1D LIDAR for autonomous navigation (with a single 1D LIDAR and two servomotors. The LIDAR will measure distances and the motors will drive the sensor in two planes horizontal (yaw) and vertical (pitch) to generate a point cloud. This 3D point cloud is further used to plot a graph of the environment.Profile of the objects that are obstacles has been generated using a simple, low cost LIDAR.)

· Other Applications:

1- Monitoring and protection systems.

2- The child's height can be measured and stored each day to monitor growth.

3- It can be placed next to the touchline or any other line to aid the referee in a match or alert when errors occur according to the laws of the game at - FIFA.com.

4- It can be used in basketball game to count goals.

We used this project to build a Hexabitz scoring system of basketball match by connecting IR module directly to Hexabitz micro SD module (H1BR60) and logging these sensor readings to a micro SD card. To power the system we can using a coin-cell battery holder module (H04R20).

You can making the Basketball Net to testing the system:

Writing code with Keil uVision

The IR module (H08R6) code :

The micro SD (H1BR6) module code:







Schematics, diagrams and documents

The Design



Ir sensor code


Array topology definition


micro SD card module code


Photo of Aula_Jazmati




Leave your feedback...