Image of Discover Radar Magic with DNG-TOF20

Discover Radar Magic with DNG-TOF20 Leave a comment

The World of Miniature Radars

In the world of drones, autonomous robots, security systems, and industrial automation, precise distance measurement is one of the most vital requirements. Among various distance measurement technologies, LiDAR (Light Detection and Ranging) technology has created a remarkable transformation as an accurate, fast, and reliable solution.

Unlike ultrasonic sensors that have limited accuracy or infrared sensors that are affected by ambient light, LiDAR is capable of measuring distance with millimeter precision using laser pulses. The DNG-TOF20 module is an advanced and cost-effective example of LiDAR technology, belonging to the category of ToF (Time-of-Flight) sensors. This module, by sending infrared laser pulses and measuring their return time, can calculate the distance to objects in the range of 0.1 to 20 meters with an accuracy of ±1 cm at a sampling rate of 200 Hz. The module supports serial (UART) and I2C communication, giving you full flexibility in your designs.

Key features of the DNG-TOF20 include low power consumption (only 0.33 watts in operating mode), resistance to ambient light (up to 100 kilolux), ability to operate in various weather conditions, and its compact size that enables mounting on moving platforms such as robots and drones.

In this article, we will examine the DNG-TOF20 module. We start with the operating principles of ToF technology and the technical specifications of the module, then teach the practical setup, communication protocol, and how to program it for microcontrollers. We will also explore the diverse applications of this module in real projects, from 3D mapping and obstacle avoidance in robotics to surveillance and industrial systems. Join us to discover the amazing world of laser-based distance measurement.

How Do LiDAR and ToF Technology Work?

LiDAR (Light Detection and Ranging) is a remote sensing technology that calculates the distance to objects by sending laser light pulses and measuring the time it takes for them to return. The foundation of LiDAR is based on ToF or Time-of-Flight – the same concept we see in athletics competitions: an object travels a path and the round-trip time is measured.

In ToF technology, a laser pulse is sent toward the target at the speed of light (≈ 300,000 km/s). After hitting the object, the pulse is reflected and returns to the sensor. By precisely measuring the round-trip time (t) and using the simple formula distance = (speed of light × time) / 2, the distance to the object is calculated. The accuracy of this method is so high that it can even detect millimeter-level changes. Later we will have a comparison of different technologies.

Technology Principle of Operation Measurement Range Accuracy Speed Environmental Sensitivity Cost Common Applications
LiDAR (ToF) – lightweight model Laser pulse + Time of Flight Few cm to several meters Very high (±1 cm) Very high (up to 200 Hz) Direct light, fog Medium Robotics, drones, mapping
Industrial / Military LiDAR Laser pulse + Time of Flight Up to 10+ km Millimeter level High Adverse weather Very high Topography, defense systems
Ultrasonic Sound waves + Echo Few cm (typical) Medium Low (10–20 Hz) Temperature, wind Very low Parking sensors, level measurement
Infrared (IR) – triangulation Angle triangulation 10 cm – 5 m Low Medium Ambient light, color Low Line following robots
mmWave Radar (RF) Millimeter radio waves 0.1 – 250 m High High Low Medium–High Autonomous vehicles, industry
Military / Airborne Radar Radio waves + Doppler Up to 400+ km Variable Very high Almost unaffected Very high Air defense, meteorology
Computer Vision (Stereo) Stereo image processing Depends on field of view Variable Low Light, texture High Face recognition, AR

As you can see in this table, various technologies exist with different applications, each suitable for specific purposes. The module we are examining here creates a good balance between low-cost but low-accuracy technologies (such as ultrasonic) and very expensive industrial systems by combining high accuracy, suitable range, and affordable price. This module is considered an ideal option for projects that need higher accuracy than ultrasonic sensors but have a limited budget for purchasing industrial LiDAR systems.

Collage of three LiDAR use cases
LiDAR-powered solutions: Real-time distance safety for cranes, precise UAV altitude control & landing, and smart traffic counting on busy roads.

Module Introduction: Technical Specifications

In the table below you can see a summary of this module’s specifications.

Item Min Typical Max Unit Description
Measurement Frequency 50 100 250 Hz Number of distance measurements per second (50/100/250 Hz)
Measurement Range 0.1 20 m With 80% reflectivity
Relative Error
30 mm 0.2 m ≤ distance < 1 m
60 mm 1 m ≤ distance ≤ 6 m
1% % distance > 6 m (percentage of measured distance)
Ambient Light Condition 100,000 lux
Operating Voltage 3.3 V
Operating Current 20 105 150 mA
Power Consumption 66 346 495 mW Based on 150 mA at 3.3 V
Operating Temperature –20 25 +50 °C
Storage Temperature –20 25 +80 °C
Dimensions (L × W × H) 21 × 15 × 7.87 mm
Weight (Net) 1.35 g Net weight

As you can see in the module specifications table, this module offers outstanding features including:

  • High accuracy
  • Impressive measurement range
  • Suitable sampling rate
  • Low sensitivity to strong ambient light
  • Very efficient power consumption
  • Compact size and lightweight design

These characteristics make it an ideal choice for projects that demand both precision and speed.

Communicating with the Module

Communication via UART

As previously mentioned, this module supports both I2C and UART protocols. You can select which communication interface to use by setting a specific pin — the one labeled INT in the image — to either logic 0 (low) or logic 1 (high).

By pulling this INT pin to 0 or 1 (usually done by connecting it to GND or VCC, or via a pull-up/pull-down configuration), you tell the module whether it should operate in UART mode or I2C mode.

This simple hardware selection gives you flexibility to integrate the DNG-TOF20 with a wide variety of microcontrollers and development boards using the interface that best suits your project.

Communication via UART vs I2C pinout
Communication UART vs I2C pinout
Discover Radar Magic with DNG-TOF20 Pinout
The pinout of the module  

 

To communicate with the module in UART mode, apply the following configuration:

  • Baud Rate: 115200
  • Parity: None
  • Data Bits: 8
  • Stop Bits: 1
  • Flow Control: None

The supported baud rate range is from 9600 (minimum) to 921600 (maximum). Important: All communication with the module must follow the protocol described below — no other formats are accepted.

Recommended Power-Up Sequence:

  1. First connect the module’s main power line to 3.3V (usually labeled 3V3 or VCC).
  2. Send any necessary configuration commands.
  3. Only then connect/apply power to the laser line (3V3_LASER) to turn on the laser emission.

UART Command Frame Format

All commands sent via UART must follow this exact structure: UART Command Frame Format

Byte Name Description
Byte 0 Head Command frame header (fixed value: 0x5A)
Byte 1 Len Total length of the command frame (including Head and Checksum, in bytes)
Byte 2 ID Command identifier (determines how to parse different commands)
Byte 3 to Byte N-2 Payload Data section; interpreted based on ID; data is in little-endian format
Byte N-1 Checksum Low 8 bits of the sum of all bytes from Head to Payload (sum & 0xFF)

As examples, you can use the following messages to access various module features:

Parameter Command Response Description Default
Get firmware version 5A 04 01 5F 5A 07 01 V1 V2 V3 SU Firmware version (e.g. V3.2.1)
System reset 5A 04 02 60 5A 05 02 00 61 (success)
5A 05 02 01 62 (fail)
Frame rate 5A 06 03 LL HH SU 5A 06 03 LL HH SU 1–1000 Hz 100 Hz
Trigger detection 5A 04 04 62 Data frame After setting frame rate to 0, this command enables detection
Output format 5A 05 05 01 65
5A 05 05 02 66
5A 05 05 06 6A
5A 05 05 01 65
5A 05 05 02 66
5A 05 05 06 6A
Standard 9-byte (cm) ✓
Pixhawk compatible
Standard 9-byte (mm)
Standard 9-byte (cm)
Baud rate 5A 08 06 H1 H2 H3 H4 SU 5A 08 06 H1 H2 H3 H4 SU Set baud rate
Example: 256000 (decimal) = 3E800 (hex), H1=00, H2=E8, H3=03, H4=00
115200
Enable/disable output 5A 05 07 00 66
5A 05 07 01 67
5A 05 07 00 66
5A 05 07 01 67
Disable data output / Enable data output ✓ Enabled
Set communication interface 5A 05 0A MODE SU 5A 05 0A 00 69
5A 05 0A 01 6A
0 (UART)
1 (I2C)
UART
Change I2C address 5A 05 0B ADDR SU 5A 05 0B ADDR SU Change I2C address 0x10
Get data frame 5A 05 00 01 60
5A 05 00 06 65
9-byte data frame (cm)
9-byte data frame (mm)
Only works in I2C mode
Enable I/O mode 5A 09 3B MODE DL DH ZoneL ZoneH SU MODE: 0 – standard data mode
1 – I/O near high & far low
2 – I/O near low & far high
Zone: hysteresis region
0 (standard data mode)
Power threshold & below-threshold distance 5A 07 22 XX LL HH 00 5A 07 22 XX LL HH SU Example: When strength < 100, output distance 1200 cm
XX=100/10=10(DEC)=0A(HEX)
1200(DEC)=4B0(HEX) LL=B0, HH=04
Power threshold = 100
Below-threshold distance = 0
Low power mode 5A 06 35 0X 00 SU 5A 06 35 0X 00 SU X range (HEX) 0~A; frame rate in low-power mode cannot exceed 10 Hz
X>0: low-power mode active
X=0: low-power mode disabled
Factory reset 5A 04 10 6E 5A 05 10 00 6F (success)
5A 05 10 01 70 (fail)
Save settings 5A 04 11 6F 5A 05 11 00 70 (success)
5A 05 11 01 71 (fail)

Communication with the Module via I2C

To use I2C, first connect the GPIO pin (mentioned earlier in the UART section) with a pull-up resistor so the module enters I2C communication mode. Then configure I2C as follows:

Parameter Value Description
Interface I²C Communication interface
Max transmission rate 400 kbit/s Data transfer speed
Master/Slave mode Slave Module operates as slave device
Default address 0x10 Default I²C address of the module
Address range 0x01 to 0x7F Configurable address range

In this communication, the microcontroller acts as Master and the module acts as Slave. First send the configuration message, then wait 100 milliseconds for the command to be processed. No waiting is required to read the measurement result. The I2C registers are as shown in the table below:

Address R/W Name Initial Value Description
0x00 R DIST_LOW Distance low byte (cm)
0x01 R DIST_HIGH Distance high byte
0x02 R AMP_LOW Amplitude low byte
0x03 R AMP_HIGH Amplitude high byte
0x04 R TEMP_LOW Temperature low byte (unit: 0.01 °C)
0x05 R TEMP_HIGH Temperature high byte
0x06 R TICK_LOW Timestamp low byte
0x07 R TICK_HIGH Timestamp high byte
0x08 Reserved Hold
0x09 R ERROR_LOW Hold
0x0A R VERSION_REVISION Revised version
0x0B R VERSION_MINOR Minor version
0x0C R VERSION_MAJOR Major version
0x0D–0x0F Reserved Hold
0x10–0x1D R SN Production code (14 bytes ASCII, 0x10 is first byte)
0x1E–0x1F Reserved Hold
0x20 W SAVE Write 0x01 to save current settings
0x21 W SHUTDOWN / REBOOT Write 0x02 to reboot
0x22 W/R SLAVE_ADDR 0x10 I²C address range: 0x08 – 0x77
0x23 W/R MODE 0x00 0x00: Continuous mode
0x01: Trigger mode
0x24 W TRIG_ONE_SHOT 0x01: Trigger once (only in trigger mode)
0x25 W/R ENABLE 0x01 0x00: Turn off LiDAR
0x01: Turn on LiDAR
0x26 W/R FPS_LOW 0x64 Frames per second low byte
0x27 W/R FPS_HIGH 0x00 Frames per second high byte
0x28 W/R HOLD Reserved
0x29 W RESTORE_FACTORY_DEFAULTS Write 0x01 to restore factory defaults
0x2A W/R AMP_THR_LOW 0x2C Amplitude threshold low byte
0x2B W/R AMP_THR_HIGH 0x01 Amplitude threshold high byte
0x2C W/R DUMMY_DIST_LOW 0xFF Dummy distance low byte
0x2D W/R DUMMY_DIST_HIGH 0xFF Dummy distance high byte
0x2E W/R MIN_DIST_LOW 0x00 Minimum distance low byte (mm)
0x2F W/R MIN_DIST_HIGH 0x00 Minimum distance high byte
0x30 W/R MAX_DIST_LOW 0xFF Maximum distance low byte (mm)
0x31 W/R MAX_DIST_HIGH 0xFF Maximum distance high byte
0x32–0x3B Reserved Hold
0x3A–0x3F R SIGNATURE ASCII string (e.g. “DNG-TOF20”)

Module Output

The TFmini Plus module can send data via the serial port in two different formats, and you can switch between these formats using a command.

  • Standard data output format (default)
  • Character string format

Character String Format In this mode, output data is sent as text with unit in meters (m). For example, if the measured distance is 1.21 meters, the output will be:

 

(i.e., after the number, CR and LF line-ending characters are sent.)

Standard Data Output Format (default) In this mode, each data frame consists of 9 bytes and contains the following information:

  1. Distance value
  2. Signal strength
  3. Chip temperature
  4. Data validity check byte (Checksum)

All data is sent in hexadecimal (HEX) and each frame is exactly 9 bytes as follows:

Byte Name Description
Byte 0 0x59 Frame header (fixed)
Byte 1 0x59 Frame header (fixed)
Byte 2 Dist_L Distance low 8 bits
Byte 3 Dist_H Distance high 8 bits
Byte 4 Strength_L Signal strength low 8 bits
Byte 5 Strength_H Signal strength high 8 bits
Byte 6 Temp_L Temperature low 8 bits
Byte 7 Temp_H Temperature high 8 bits
Byte 8 Checksum Low 8 bits of sum of bytes 0 to 7

🔗Important Notes

Distance represents the measured distance by the module, which is sent by default in centimeters as a decimal value.

Strength represents the returned signal strength and by default is in the range 0 to 65535.

If signal strength is less than 100 or equal to 65535 (saturation or overexposed condition occurs), the measurement is invalid and the module sets the distance value to 0.

Example of received packets:

Testing the Module on Windows

For this, you need the (WINCC_TF) program which you can download from this link. After that, set up the module in the order previously described and communicate with the module using a USB-Serial converter and the downloaded program, similar to what is shown in the image.

Screenshot of SW-TF550 software showing time-line chart
Testing the Module on WINCC_TF

Communicating with the Module Using a Microcontroller

Programming for this module is not difficult because you have all the necessary information, but to speed up the product development process, here we will examine the code we have prepared for you.

In this code, first the correct establishment of communication is checked, then a request to receive information is sent to the module via UART, and the data is checked and displayed.

The Arduino sketch is as follows:

First, by requesting the firmware version, we check that the hardware connections are correctly established, and then we use the read Data function. This function extracts the distance, strength, and temperature from the packet sent by the module and displays them. It also checks the Checksum and Strength, and if they have incorrect values, it notifies the user.

This function is as follows:

If the program works correctly, you will have an output like the following:

 

Log excerpt from TFS showing repeated distance
Correct output

To download and use this code, you can visit the following Git address.
I hope you have made full use of this article and support us with your good comments:)

🔗Purchase DNG-TOF20 Module

If you are looking for a compact, high-speed, and accurate LiDAR module for your robotics, drone, industrial automation, or smart sensing projects, you can purchase the DNG-TOF20 module directly from EICUT Store and start developing your project with a reliable ToF distance measurement solution.

Leave a Reply