Reference
Last revision 2026/01/07
The article offers a detailed exploration of the URM09 ultrasonic sensor, including library installation processes for Arduino and Raspberry Pi, communication protocol descriptions for different sensor versions, and API functionalities for effective sensor operation and data reading.
Library
Library files applicable to Arduino and Raspberry Pi development environments:
- URM09 library
- Arduino Library Installation: (About how to install the library?)
- Raspberry Pi Library Installation: (About how to install the library?)
Communication Protocol Description
The module uses I2C communication. Below are the register descriptions for different versions:
URM09 Ultrasonic Sensor(Gravity I²C)(V1.0) Register
| Register(8bit) | Name | R/W | Data Range | Default Value | Description |
|---|---|---|---|---|---|
| 0x00 | Device Address | R/W | 0x08-0x77 | 0x11 | I2C salve address, the default address is 0x11. If the address is changed, the new address will be valid after repowering the module. |
| 0x01 | Product ID | R | 0x01 | Used for product check | |
| 0x02 | Version Number | R | 0x10 | Used for Version check(0x10 means V1.0) | |
| 0x03 | Distance Value High-order bits | R | 0x00-0xFF | 0x00 | LSB represents 1CM. e.g. 0x64 represents 100CM |
| 0x04 | Distance Value Low-order bits | R | 0x00-0xFF | 0x00 | LSB represents 1CM. e.g. 0x64 represents 100CM |
| 0x05 | Temperature Value High-order bits | R | 0x00-0xFF | 0x00 | 10 times amplified value based on the real temperature. e.g. if the readout value is 0x00fe, the real temperature value should be 0x00fe / 10 = 25.4℃ |
| 0x06 | Temperature Value Low-order bits | R | 0x00-0xFF | 0x00 | 10 times amplified value based on the real temperature. e.g. if the readout value is 0x00fe, the real temperature value should be 0x00fe / 10 = 25.4℃ |
| 0x07 | Configure Registers | R/W | 0x00 | Bit7(control bit in ranging mode) 0: passive measurement, send ranging command once, the module ranges the distance once and store the measured value into the distance register. 1: automatic measurement mode, the module keeps ranging distance and updating the distance register all the time. Bit6: save Bit5-bit4(the maximum ranging distance bit that can be set) 00:150CM(the ranging cycle is about 20MS) 01:300CM(the ranging cycle is about 30MS) 10:500CM(the ranging cycle is about 40MS) |
|
| 0x08 | Command Registers | R/W | 0x00 | Writing 0X01 to this register under passive measurement mode and the module ranges distance once. The write data is invalid under automatic measurement mode. |
URM09 Ultrasonic Sensor(Gravity I²C)(V3.0) Register
| Register(8bit) | Name | R/W | Data Range | Default Value | Descripyion |
|---|---|---|---|---|---|
| 0x00 | Device Address | R/W | 0x08-0x77 | 0x11 | I2C salve address, the default address is 0x11. If the address is changed, the new address will be valid after repowering the module. |
| 0x01 | Product ID | R | 0x01 | Used for product check | |
| 0x02 | Version Number | R | 0x10 | Used for Version check(0x10 means V1.0) | |
| 0x03 | Distance Value High-order bits | R | 0x00-0xFF | 0x00 | LSB represents 1cm. e.g. 0x64 represents 100cm |
| 0x04 | Distance Value Low-order bits | R | 0x00-0xFF | 0x00 | LSB represents 1cm. e.g. 0x64 represents 100cm |
| 0x05 | Temperature Value High-order bits | R | 0x00-0xFF | 0x00 | 10 times amplified value based on the real temperature. e.g. if the readout value is 0x00fe, the real temperature value should be 0x00fe / 10 = 25.4℃ |
| 0x06 | Temperature Value Low-order bits | R | 0x00-0xFF | 0x00 | 10 times amplified value based on the real temperature. e.g. if the readout value is 0x00fe, the real temperature value should be 0x00fe / 10 = 25.4℃ |
| 0x07 | Configure Registers | R/W | 0x00 | Bit7(control bit in ranging mode) 0: passive measurement, send ranging command once, the module ranges the distance once and store the measured value into the distance register. 1: automatic measurement mode, the module keeps ranging distance and updating the distance register all the time. |
|
| 0x08 | Command Registers | R/W | 0x00 | Writing 0x01 to this register under passive measurement mode and the module ranges distance once. The write data is invalid under automatic measurement mode. |
Note: The new version has cancelled the program option to switch between the measuring ranges of 150cm, 300cm, and 500cm, and has optimized the distance measuring solution to enhance the stability of the product and the compatibility of the probe. Therefore, although the code in the library has not been accordingly modified, using the software program to configure the measuring range will not produce any effect.
API Description
Arduino API
DFRobot_URM09 URM09: Creates a URM09 object for I2C communication.URM09.begin(): Initializes the sensor with the default I2C address (0x11). Returnstrueif successful.URM09.setModeRange(mode, range): Configures the measurement mode (automatic/passive) and range (150/300/500cm).URM09.measurement(): Sends a ranging command (passive mode only).URM09.getDistance(): Reads the distance value (in cm) from the sensor.URM09.getTemperature(): Reads the temperature value (in °C) from the sensor.
Raspberry Pi API
URM09 = URM09.DFRobot_URM09(): Creates a URM09 object for I2C communication.URM09.begin(address): Initializes the sensor with the specified I2C address.URM09.SetModeRange(mode, range): Configures the measurement mode (automatic/passive) and range (150/300/500cm).URM09.SetMeasurement(): Sends a ranging command (passive mode only).URM09.i2cReadDistance(): Reads the distance value (in cm) from the sensor.URM09.i2cReadTemperature(): Reads the temperature value (10x amplified) from the sensor. Divide by 10 to get the actual temperature in °C.
Other Supplementary Information
-
Version Note: Compared with URM09 V1.0, the latest URM09 V2.0 just improved the layout to improve its stability. And the dimension and function of V1.0 and V2.0 is the same.
-
More Documents:
Was this article helpful?
