Reference
Last revision 2025/12/20
The article provides a comprehensive overview of ultrasonic sensor communication protocols and API usage for Arduino and Raspberry Pi, detailing UART output data, checksum calculation, and distance measurement principles.
Library
- Arduino: SoftwareSerial library (included with Arduino IDE)
- Raspberry Pi: Ultrasonic Sensor Library
Communication Protocol Description
Output Communication
When "RX" floats or input High level, the module outputs processed value, the data is more steady, response time: 150-300ms; when input Low level, the module outputs real-time value, response time: 150ms.
| UART | Data bit | Stop bit | Parity | Band rate |
|---|---|---|---|---|
| TTL level | 8 | 1 | none | 9600bps |
UART Output Form
| Frame Data | Description | Byte |
|---|---|---|
| Header | 0xFF | 1 byte |
| DATA_H | Distance Data High 8-bits | 1 byte |
| DATA_L | Distance Data Low 8-bits | 1 byte |
| SUM | Checksum | 1 byte |
UART Output
| Header | DATA_H | DATA_L | SUM |
|---|---|---|---|
| 0xFF | 0x07 | 0xA1 | 0xA7 |
checksum only reserves the low 8-bits of the accumulated value.
SUM=(Header+Data_H+Data_L)&0x00FF
=(0XFF + 0X07 + 0XA1)&0x00FF
=0XA7;
Distance= Data_H*256+ Data_L=0X07A1;
Equal to 1953 when converted into decimal;
Represent the current measured distance is 1953mm.
Principle
Ultrasonic distance sensor determines the distance to a target by measuring time lapses between the sending and receiving of the ultrasonic pulse.
Other Supplementary Information
- STP Model
- Installation Dimension:

Was this article helpful?
