Reference
The article details UART communication protocol, covering interface settings, timing diagrams, output formats, and checksum calculations to accurately measure distance in centimeters.
Communication Protocol Description
1、communication instructions
| Interface | Baud rate | Data bit | Stop bit | Check bit |
|---|---|---|---|---|
| UART | 9600bps | 8 | 1 | None |
2、Timing diagram

Note: T1>2.5s, T2=0.9~2.5s; RX falling edge trigger pulse width is recommended to be between 10us-2ms
3、UART output format
| Frame data | Output data | Description | Bytes |
|---|---|---|---|
| Frame header | 0XFF | Frame header, fixed as 0XFF | 1 byte |
| H_DATA | 0X01 | Higher 8 bits of distance data | 1 byte |
| L_DATA | 0XA1 | Lower 8 bits of distance data | 1 byte |
| SUM | 0XA1 | data checksum | 1 byte |
SUM= (header+Data_H+ Data_L)&0x00FF
=(0XFF + 0X01 + 0XA1)&0x00FF
=0XA1;
Distance value = DATA_ H * 256+DATA_L = 0x01A1;
Decimal conversion is equal to 417,Indicates that the currently measured distance value is 417cm.
Was this article helpful?
