yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
TinyF Laser Ranging Module📖
1. Introduction to TinyF laser ranging module
  • 1. Introduction to TinyF laser ranging module
2. Get distance information_PC
  • 2. Get distance information_PC
3. Get distance information_MasterControl
  • arduino
  • esp32
  • Jetson
  • microbit
  • mspm0g3507
  • mspm0g3519new
  • raspberry
  • RDK
  • stm32
Download
  • Code
  • 3D_Model_File
  • UART-Software
  • Data_Sheet
Download ZIP

Welcome to TinyF Laser Ranging Module repository

Jetson

TinyF and jetson serial communication

TinyF and jetson serial communication0. Introduction to TinyF1. Experimental Preparation2.Experimental wiring3. Main code explanation4. Experimental Phenomena5.Some important parameters of TinyF

0. Introduction to TinyF

  • The TinyF laser ranging module is based on a D-TOF single-point laser sensor, an onboard MCU, and a housing. It features built-in sunlight rejection and anti-cover contamination algorithms, enabling accurate and rapid distance measurement. Even in extremely bright ambient light (100-190K Lux), it can accurately measure even the smallest objects, unaffected by variations in reflectivity, achieving precise ranging of 2m to 4m.

1. Experimental Preparation

  • TinyF Laser Distance Measurement Module
  • Jetson Series: This tutorial uses the Jetson Nano B01
  • USB to TTL Module

2.Experimental wiring

USB to TTLTinyF
TXDRX
RXDTX
GNDGND
5V5V

Wiring diagram

image-20250811154310788

 

 

3. Main code explanation

​x
def parse_data_format(self, data_bytes):
        try:
            # 查找逗号分隔符的位置 (0x2C) Find the position of the comma separator (0x2C)
            comma_index = -1
            for i, b in enumerate(data_bytes):
                if b == 0x2C:
                    comma_index = i
                    break
            
            if comma_index == -1:
                return None, None
            
            # 提取距离部分 (逗号前的数据)  Extract the distance part (the data before the comma)
            # 跳过开头的空格(0x20)  Skip the initial space (0x20)
            start_index = 0
            while start_index < comma_index and data_bytes[start_index] == 0x20:
                start_index += 1
            # 距离数据长度 (2-5字节) Distance data length (2-5 bytes) :
            distance_bytes = data_bytes[start_index:comma_index]  
            
            # 提取置信度部分 (逗号后的数据) Extract the confidence part (the data after the comma)
            # 跳过逗号后的空格(0x20) The space after the comma (0x20)
            confidence_start = comma_index + 1
            while confidence_start < len(data_bytes) and data_bytes[confidence_start] == 0x20:
                confidence_start += 1
            
            # 置信度数据应为1-2字节:原始数据 The confidence data should be 1-2 bytes: raw data
            confidence_bytes = data_bytes[confidence_start:len(data_bytes)-1]
            
            # 转换距离数据 Convert distance data
            distance_str = distance_bytes.decode('ascii')
            distance = int(distance_str)
            if distance >4000:
                return None,None
                
            # 转换置信度数据 Convert the confidence level data
            confidence_str = confidence_bytes.decode('ascii')
            confidence = int(confidence_str)
            
            return distance, confidence
        except Exception as e:
            print(f"parse_error: {e}")
            return None, None
            
            .....
​
if __name__ == "__main__":
    # 根据设备实际串口号进行替换  Replace according to the actual serial port number of the device
    SERIAL_PORT = "/dev/ttyUSB0" 
    BAUD_RATE = 115200
    parser = DistanceDataParser(serial_port=SERIAL_PORT, baud_rate=BAUD_RATE)
    parser.start_processing()      

The above program parses data from the TinyF laser ranging module. Data can only be correctly parsed if it complies with the protocol.

If more than one USB device is connected, please confirm the USB device number on the USB-to-TTL converter and modify the port value.

4. Experimental Phenomena

  1. Connect the wires according to the wiring diagram.

2.If the serial port driver library is not installed in Python 3, run the following command to install it.

xxxxxxxxxx
pip3 install pyserial
  1. You need to upload the uart_test.py program to Jetson in advance, and then enter the following command in the terminal
xxxxxxxxxx
python3 uart_test.py
  1. After running the command, the terminal will print the ranging information

image-20250807161907660

5.Some important parameters of TinyF

Related parameter description

namevalue
Baud rate115200
Effective minimum distance (theoretical value)20,unit:mm
Effective maximum distance (theoretical value)4000,unit:mm
Confidence0~62,The larger the value, the higher the distance reliability.

Data format

Data frame structure: image-20250806182406790

Example: image-20250806182514571

FieldNumber of bytesExample(Hex)ASCII characters
Frame header (fixed value)120space
Distance value(distance)1~533 32 37327
Delimiter (fixed value)22C 20,space
Confidence(confidence)1~236 3161
Frame tail (fixed value)10A\n
esp32
microbit

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文