Reference
Driver
- Serial driver: CP210x_Windows_Drivers_v6.7.6.zip
Communication Protocol Description
The below takes single-module continuous ranging as an example.
UART Active Output Mode
The protocol consists of Frame Header, Function Mark, Data, and Sum Check. Among them, Frame Header and Function Mark are fixed values; Data is the transmitted data content, and Sum Check is the lowest byte after adding Frame Header, Function Mark, and Data (that is, adding all the preceding bytes). Protocol composition: Frame Header + Function Mark + Data + Sum Check
Original data: 57 00 ff 00 9e 8f 00 00 ad 08 00 00 03 00 ff 3a
The command format is as follows:
| Data | Type | Length(Bytes) | Hex | Results |
|---|---|---|---|---|
| Frame Header | uint8 | 1 | 57 | 0x57 |
| Function Mark | uint8 | 1 | 00 | 0x00 |
| reserved | uint8 | 1 | ... | * |
| id | uint8 | 1 | 00 | 0 |
| System_time | uint32 | 4 | 9c 8f 00 00 | 36766ms |
| dis*1000 | uint24 | 3 | ad 08 00 | 2.221m |
| dis_status | uint8 | 1 | 00 | 0 |
| signal_strength | uint16 | 2 | 03 00 | 3 |
| range_precision | uint8 | 1 | 06 | 6cm |
| Sum Check | uint8 | 1 | 41 | 0x41 |
Special, for the int24 type, we need to convert it to int32 type first. To maintain the sign, we use the left shift operation followed by division by 256. For example, for position data represented in int24, with a multiplier of 1000.
uint8_t byte[] = {0xe6,0x0e,0x00};//代表十进制数值:3.814
//uint8_t byte[] = {0xec,0xfb,0xff};//代表十进制数值:-1.044
int32_t temp = (int32_t)(byte[0] << 8 | byte[1] << 16 | byte[2] << 24) / 256;
float result = temp/1000.0f
UART Query Output Mode
Original data: 57 10 FF FF 00 FF FF 63
The command format is as follows:
| Data | Type | Length(Bytes) | Hex | Results |
|---|---|---|---|---|
| Frame Header | uint8 | 1 | 57 | 0x57 |
| Function Mark | uint8 | 1 | 10 | 0x10 |
| reserved | uint16 | 2 | ... | * |
| id | uint8 | 1 | 00 | 0 |
| reserved | uint16 | 2 | ... | * |
| Sum Check | uint8 | 1 | 63 | 0x63 |
I2C Communication Mode
Slave address: The module works as a slave in the IIC bus, the default address is 0x08 (7-bit address), and the slave address is 0x08+module ID. You can change the slave address by changing the ID parameter of the module. When communicating, pay attention to address shifting and adding read and write bits, that is, when the address is 0x08, the bytes with read and write bits sent are 0x10 (write) and 0x11 (read).
Register address: If there is no corresponding parameter in the register, the default output is 0xff. Refer to the table below.

I2C Communication Process
Single data write

Single data read

Multiple data write

Start: start signal
W: Write flag bit 1
R: Read flag bit 0
ACK: Acknowledgment
NACK: Non-acknowledgment
Stop: Stop signal

Other Supplementary Information
Interface and Baud Rate
The module supports configuration as UART, IIC, I/O communication mode, the factory default is UART communication. If you need to use other communication modes, you can configure it through the module host computer.
Host download:
64bitnassistant_windows_64bit.zip
32bitnassistant_windows_32bit.zip
UART
Under serial communication, the baud rate setting range is as follows.
| UART_Baudrate | Note |
|---|---|
| 115200,230400,460800,921600,1000000,1200000, 1500000,2000000,3000000 | Default Baud Rate 921600 |
I2C
In IIC output mode, the baud rate setting range is shown in the table below.
| IIC_Baudrate | Note |
|---|---|
| Up to 400K | The maximum baud rate is 400Kbps, determined by the host. |
The IIC slave address of the current module. The setting range is as follows:
| IIC_Address | Note |
|---|---|
| 0x08~0x77 | The default address is 0x08 (7-bit address), and the slave address is 0x08+module ID. The slave address can be changed by changing the ID parameter of the module. The ID setting range is 0~111. Pay attention to shifting and increasing the read and write bits when communicating, that is, when the address is 0x08, the bytes with read and write bits sent are 0x10 (write), 0x11 (read) |
Distance Status
The module can output the current distance status, and the user can process data in combination with the distance status. The specific meaning is shown in the following table.
| Value | Note |
|---|---|
| 0 | Valid distance measurement |
| 1 | Invalid measurement |
Signal Strength
Indicates the strength of the current return signal, the larger the value, the stronger the return signal.
Range Precision
Indicates the accuracy of the current ranging, the smaller the value, the better the ranging accuracy.
FOV
The size of the FOV determines the field of view of the module, and the field of view of the module is 1~2°.
Mode Switch
If the module is in UART mode, you can connect NAssistant software to switch to IIC or I/O mode. If the module is in IIC mode, it needs to send a command to the module through IIC communication to switch back to UART mode. In addition, you can switch back to UART mode in the following ways when there is no IIC test environment or after switching to I/O mode:
You need to prepare a USB to TTL module that supports 921600 baud rate (CP2102 is recommended) and install the corresponding driver. Connect the TX, RX, and GND lines of the USB to TTL module to the corresponding pins of the TOF module, and leave the VCC pin temporarily unconnected. Then insert the USB to TTL module into the computer, open our host computer software, click
icon to enter the serial port debugging assistant, change the baud rate to 921600, select the COM port corresponding to the USB to TTL module, then click the connect button
to connect the COM port (it will connect automatically in most cases). Enter 54 20 00 ff 00 ff ff ff ff 00 ff ff 00 10 0e ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 7b in the Single Send text box. Change the sending interval to 20ms in the timing sending column in the lower right corner, then check the timing transmission
, at this time connect the 5V of the USB to TTL module to the VCC pin of the TOF module, the module will switch to UART mode and start outputting data. At this point, unplug the USB to TTL module, power on the module again, and click the identification button
on the main page to identify the module. If the switch fails or the output data is abnormal, you can repeat the whole step.
Was this article helpful?
