DFRobot URM09_Ultrasonic_Sensor_(Gravity-I2C)_(V1.0)_SKU_SEN0304

Introduction

This is an ultrasonic distance sensor module with open dual probe. It adopts I2C communication and standard interface of Gravity PH2.0-4P vertical patch socket. The module is compatible with controllers with 3.3V or 5V logical level, such as Arduino and Raspberry Pi. The ultrasonic sensor comes with built-in temperature compensation, providing effective ranging within 2cm to 500cm. It offers resolution of 1cm and accuracy of ±1%. There are three measurement ranges designed for programs to select: 150cm, 300cm, 500cm. Please note that setting shorter range will cause shorter ranging cycle and lower sensitivity. You may need to set it according to the actual use.

Specification

Pinout

Pinout

NOTE: Compared with URM09 V1.0, the 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.

Pin Description
VCC Power Supply(3.3V-5.5V)
GND Ground
C I2C SLC
D I2C SDA

Tutorial

URM09 is a simple and practical ultrasonic sensor. It adopts I2C communication, which is very convenient to communicate with other boards that is equipped with I2C interface.

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.

Connection Diagram

Connect the module to UNO via I2C interface, shown as below.

Connection

Distance and Temperature Measurement on Arduino

The default measurement mode is passive mode. Send ranging command by write register, and then the module will start ranging once after receiving the command(ranging cycle is related to measurement range). When finished the measurement, the read distance register could obtain a distance value. When measuring the temperature, just read the temperature register and then the measured value can be available after simple processing.

Sample Code

/*!
 * @file PassiveMesure.ino
 * @brief Passive measurement of distance and temperature
 * @n This example is the ultrasonic passive measurement of distance and module temperature and printing on the serial port
 * @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @license The MIT License (MIT)
 * @author ZhixinLiu(zhixin.liu@dfrobot.com)
 * @version version  V1.2
 * @date 2020-9-30
 * @url https://github.com/DFRobot/DFRobot_URM09
 */
#include "DFRobot_URM09.h"

/* Create a URM09 object to communicate with IIC. */
DFRobot_URM09 URM09;

void setup() {
  Serial.begin(115200);
  /**
   * I2c device number 1-127
   * When the i2c device number is not passed, the default parameter is 0x11
   */
  while(!URM09.begin()){
    Serial.println("I2C device number error ");
    delay(1000);
  }
  /**
   * The module is configured in automatic mode or passive
   *  MEASURE_MODE_AUTOMATIC       automatic mode
   *  MEASURE_MODE_PASSIVE         passive mode
   * The measurement distance is set to 500,300,150 
   *  MEASURE_RANG_500             Ranging from 500 
   *  MEASURE_RANG_300             Ranging from 300 
   *  MEASURE_RANG_150             Ranging from 150 
  */
  URM09.setModeRange(MEASURE_MODE_PASSIVE ,MEASURE_RANG_500);   
  delay(100);
}

void loop() {
  URM09.measurement();                         // Send ranging command 
  delay(100);
  int16_t dist = URM09.getDistance();          // Read distance
  float   temp = URM09.getTemperature();       // Read temperature
  Serial.print(dist, DEC); Serial.print(" cm------"); 
  Serial.print(temp, 1); Serial.println(" C");
  delay(100);
}

Result

Result

Distance and Temperature Measurement on Raspberry Pi

# -*- coding:utf-8 -*-
'''
    # PassiveMeasure.py
    #
    # Connect board with raspberryPi.
    # Make board power and URM09 connection correct.
    # Run this demo.
    #
    # Set the i2c communication device number.
    # Set test mode and distance.
    # Get temperature and distance data.
    #
    # Copyright   [DFRobot](http://www.dfrobot.com), 2016
    # Copyright   GNU Lesser General Public License
    #
    # version  V2.0
    # date  2019-7-09
'''
import sys
import time

import URM09

sys.path.append("../..")
''' Create a URM09 object to communicate with I2C. '''
URM09 = URM09.DFRobot_URM09()
''' Set the i2c device number '''
URM09.begin(0x11)
time.sleep(0.1)
'''
    # The module is configured in automatic mode or passive
    #  _MEASURE_MODE_AUTOMATIC        // automatic mode
    #  _MEASURE_MODE_PASSIVE          // passive mode

    # The measurement distance is set to 500,300,100
    #  _MEASURE_RANG_500              // Ranging from 500
    #  _MEASURE_RANG_300              // Ranging from 300
    #  _MEASURE_RANG_150              // Ranging from 100
'''
URM09.SetModeRange(URM09._MEASURE_MODE_PASSIVE, URM09._MEASURE_RANG_500)
while(1):
    ''' Write command register and send ranging command '''
    URM09.SetMeasurement()
    time.sleep(0.1)
    ''' Read distance register '''
    dist = URM09.i2cReadDistance()
    ''' Read temperature register '''
    temp = URM09.i2cReadTemperature()

    print("Temperature is %.2f .c    " % (temp / 10))
    print("Distance is %d cm         " % dist)
    time.sleep(0.1)

Expected Result

Result 2

FAQ

Q&A Some general Arduino Problems/FAQ/Tips
A For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents