URM08-RS485 Waterproof Ultrasonic Sensor Wiki - DFRobot

Introduction

What is an ultrasonic distance sensor?

Our ultrasonic distance sensor is a ranging directional sensor equipped with an IC chip. The distance from the sensor to an obstacle can be calculated by the time difference between sending an ultrasonic signal and receiving that reflected sound. Ultrasonic sensors are widely applied to various industries and robot control areas, and offer convenient control and high efficiency in real time data feedback.

URM08-RS485 waterproof sonar range finder from DFRobot is an ultrasonic distance sensor designed for professional industry controls and robotic controls. The sensor is equipped with distance and temperature measurement functions. Additionaly, the built-in temperature compensation greatly enhances the accuracy of distance measurement.

The internal elements of the sensor are completely sealed. The sensor adopts all metal outer case, which makes it able to protect against dust, water and corrosion. In the end the sensor has high standard device selections, a much narrower blind area and wider distance detection range.

URM08-RS485 employs RS485 communication interface, and supports modbus protocol and cascaded control functions. This ultrasonic distance sensor is very suitable for a liquid level monitoring system or obstacle avoidance applications.

Specification

URM08-RS485 Beam Angle-DFRobot

Interface Description

URM08-RS485 Interface Description

Users can connect the sensor via PH2.0-4P joint and RS485 interface, the corresponding wiring order is as below:

Communication Protocol

Factory parameters:

Communication Command Frame Format:

Header Address Data Length Command Data Checksum
0x55 0xAA 1 byte 1 byte Data 1~Data n 1 byte

Commands List:

Read distance Read temperature Set address Set baud rate
0x02 0x03 0x55 0x08

Note: the following test operation needs an USB-to-RS485 converter. Visit the website to shop.

Read Distance

The host sends a frame command to the ultrasonic module through the RS485 interface to trigger the module to start detecting, and then receives the distance value command returned by the module.

For example, if the address of the ultrasonic module is 0x11, the host sends: 0x55 0xAA 0x11 0x00 0x02 0x12// Read measured distance [ 55 AA 11 00 02 12 ]

Description:
Frame header --------- 0x55
Frame header --------- 0xAA
Device address ----- 0x11
Data length ----- 0x00
Command --------- 0x02
Checksum ------- 0x12

The ultrasonic module returns data as: 0x55 0xAA 0x11 0x02 0x02 0x00 0xCA 0xDE

Description:
Frame header --------- 0x55
Frame header --------- 0xAA
Local address ----- 0x11
Data length ----- 0x02
Command --------- 0x02
Distance High ----- 0x00
Distance low ----- 0xCA (Distance value 0x00CA unit is centimeter, that is, 202 cm in decimal)
Checksum ------- 0xDE

URM08 Temperature Measurement

Read Temperature

The host reads the current temperature measured by the ultrasonic module via the RS485 interface.

For example, if the ultrasonic module address is 0x11, the host sends: 0x55 0xAA 0x11 0x00 0x03 0x13// Read the current temperature [ 55 AA 11 00 03 13 ]

Description:
Frame header --------- 0x55
Frame header --------- 0xAA
Device address ----- 0x11
Data length ----- 0x00
Command --------- 0x03
Checksum ------- 0x13

The ultrasonic module returns data as: 0x55 0xAA 0x11 0x02 0x03 0x01 0x13 0x29

Description: Frame header --------- 0x55
Frame header --------- 0xAA
Local address ----- 0x11
Data length ----- 0x02
Command --------- 0x03
Temperature high ----- 0x01
Temperature low ----- 0x13 (temperature value 0x0113, 27.5 degrees. Note: T = Returned value/10)
Checksum ------- 0x29

URM08 Temperature Measurement

Set the Address of the Ultrasonic Module

The host sets the ultrasonic module address via the RS485 interface.

For example, set the ultrasonic module address 0x12, the host sends: 0x55 0xAA 0xAB 0x01 0x55 0x12 0x12// Set ultrasonic address [ 55 AA AB 01 55 12 12 ]

Description:
Frame header --------- 0x55
Frame header --------- 0xAA
Device address ----- 0xAB (0xAB for the broadcast address, that is, all the common address of the module, you can use 0xAB to replace the device’s address if you are not sure about the current Address)
Data length ----- 0x01
Command --------- 0x55
Set the address ----- 0x12 (set the device address to 0x12)
Checksum ------- 0x12

If it succeeds, the ultrasonic module return command as 0x55 0xAA 0x12 0x01 0x55 0xCC 0x33

Description:
Frame header --------- 0x55
Frame header --------- 0xAA
Device address ----- 0x12 (modified device address)
Data length ----- 0x01
Command --------- 0x55
Operation status ----- 0xCC (0xCC - operation completed 0xEE - operation failed)
Checksum ------- 0x33

URM08 Modify the Address

Set the RS485 Communication Baud Rate

The host sets the ultrasonic module communication baud rate via the RS485 interface.

For example, if the address of the ultrasonic module is set to 0x11, the host sends: 0x55 0xAA 0x11 0x01 0x08 0x0B 0x24 //Set baudrate to 256000bps [ 55 AA 11 01 08 0B 24 ]

Description:
Frame header --------- 0x55
Frame header --------- 0xAA
Device address ----- 0x11
Data length ----- 0x01
Command --------- 0x08
Baud rate selection --- 0x0B
Checksum ------- 0x24

If the setting is successful, the ultrasonic module returns the command as: 0x55 0xAA 0x11 0x01 0x08 0xCC 0xE5

Description:
Frame header --------- 0x55
Frame header --------- 0xAA
Device address ----- 0x11
Data length ----- 0x01
Command --------- 0x08
Operation status ----- 0xCC (0xCC - operation completed 0xEE - operation failed)
Checksum ------- 0xE5

URM08 Modify the Baudrate

Baud rate Selection List:

1200bps 2400bps 4800bps 9600bps 14400bps 19200bps 28800bps 38400bps 57600bps 115200bps 128000bps 256000bps
0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B

For example, when the device address is 0x11 by default, the baud rate setting command is as follows:

55 AA 11 01 08 00 19 //Set the baud rate 1200bps
55 AA 11 01 08 01 1A //Set the baud rate 2400bps
55 AA 11 01 08 02 1B //Set the baud rate 4800bps
55 AA 11 01 08 03 1C //Set the baud rate 9600bps
55 AA 11 01 08 04 1D //Set the baud rate 14400bps
55 AA 11 01 08 05 1E //Set the baud rate 19200bps
55 AA 11 01 08 06 1F //Set the baud rate 28800bps
55 AA 11 01 08 07 20 //Set the baud rate 38400bps
55 AA 11 01 08 08 21 //Set the baud rate 57600bps
55 AA 11 01 08 09 22 //Set the baud rate 115200bps
55 AA 11 01 08 0A 23 //Set the baud rate 128000bps
55 AA 11 01 08 0B 24 //Set the baud rate 256000bps

Tutorial (Measurement by Single URM08-RS485)

Requirements

Connection Diagram

URM08-RS485 Connection Diagram

warning_yellow.png NOTE: Because Leonardo UART communication needs converted to RS485, here we used RS485 expansion board.

Tutorial 1 Distance Measurement

SEN0246 Distance Measurement

Sample code
/**************************************************************************************************************
*This code tests the range finder function of the URM08-RS485 Waterproof Sonar Range Finder
*@ author : roker.wang@dfrobot.com
*@ data   : 11.09.2017
*@ version: 1.0
*RX(TTL-RS485 converter) -> TX1/D1 (Arduino Leonardo)  TX(TTL-RS485 converter)-> RX1/D0 (Arduino Leonardo)
**************************************************************************************************************/
#define header_H    0x55 //Frame header
#define header_L    0xAA //Frame header
#define device_Addr 0x11 //Module address
#define data_Length 0x00 //Data length
#define get_Dis_CMD 0x02 //Distance measurement commands
#define checksum    (header_H+header_L+device_Addr+data_Length+get_Dis_CMD) //Checksum

//#define  CE          2
#define  TX_EN()     digitalWrite(CE,HIGH)
#define  RX_EN()     digitalWrite(CE,LOW)
unsigned char i=0;
unsigned int  Distance=0;
unsigned char Rx_DATA[8];
unsigned char CMD[6]={header_H,header_L,device_Addr,data_Length,get_Dis_CMD,checksum}; //Distance measurement command packet

void setup() {
  Serial1.begin(19200);  //Communicate with module via Serial1, set baud rate to 19200
  Serial.begin(19200);   //Set Serial as a serial port of data output
  //pinMode(CE,OUTPUT);
}


void loop() {
 //TX_EN() ;
 for(i=0;i<6;i++){
    Serial1.write(CMD[i]);
    }
 // RX_EN() ;
 delay(150);  //Wait for the end of distance measurement
 i=0;
 while (Serial1.available()){  //Read return data package (NOTE: Demo is just for your reference, the data package haven't be calibrated yet)
    Rx_DATA[i++]=(Serial1.read());
    }
 Distance=((Rx_DATA[5]<<8)|Rx_DATA[6]); //Get the distance data
 Serial.print(Distance);               //Print distance
 Serial.println("cm");
}

Tutorial 2 Temperature Measurement

SEN0246 Temperature Measurement Example

Sample code
/**************************************************************************************************************
*This code tests the temperature measurement function of the URM08-RS485 Waterproof Sonar Range Finder
*@ author : roker.wang@dfrobot.com
*@ data   : 11.09.2017
*@ version: 1.0
*RX(TTL-RS485 converter) -> TX1/D1 (Arduino Leonardo)  TX(TTL-RS485 converter)-> RX1/D0 (Arduino Leonardo)
**************************************************************************************************************/

#define header_H     0x55 //Frame header
#define header_L     0xAA //Frame header
#define device_Addr  0x11 //Module address
#define data_Length  0x00 //Data length
#define get_Temp_CMD 0x03 //A temperature measurement command
#define checksum     (header_H+header_L+device_Addr+data_Length+get_Temp_CMD) //Checksum

unsigned char i=0;
int  temperature=0;
unsigned char Rx_DATA[8];
unsigned char CMD[6]={header_H,header_L,device_Addr,data_Length,get_Temp_CMD,checksum}; //temperature  measurement command packet
void setup() {
  Serial1.begin(19200);  //Communicate with module via Serial1, set baud rate to 19200
  Serial.begin(19200);   //Set Serial to serial port of data output
}

void loop() {
 for(i=0;i<6;i++){
    Serial1.write(CMD[i]);
    }
 delay(50);  //Wait data to return
 i=0;
 while (Serial1.available()){  //Read return data package (NOTE: Demo is just for your reference, the data package haven't be calibrated yet)
    Rx_DATA[i++]=(Serial1.read());
    }
 temperature=((Rx_DATA[5]<<8)|Rx_DATA[6]);  //Get temperature(10 times temperature value here)
 Serial.print(temperature/10);             //Print temperature
 Serial.print('.');
 Serial.print(temperature%10);
 Serial.println("C");
}

Tutorial (Measurement by Multiple URM08-RS485s)

SEN0246_Multiple URM08-RS485s Connection Diagram

warning_yellow.png Note: Connect the mutiple RUM08-RS485 modules to serial bus, then set different addresses for each URM08 mdoule before using.(There are four URM08 sensor in this sample, set their address to: 0x11, 0x22, 0x33, 0x44)

SEN0246_Multiple URM08-RS485s Distance Measurement Example

Sample Code

/**************************************************************************************************************
*This code tests the range finder function of multiple URM08-RS485 Waterproof Sonar Range Finder
*@ author : roker.wang@dfrobot.com
*@ data   : 11.09.2017
*@ version: 1.0
*RX(TTL-RS485 converter) -> TX1/D1 (Arduino Leonardo)  TX(TTL-RS485 converter)-> RX1/D0 (Arduino Leonardo)
**************************************************************************************************************/

unsigned char i=0,j=0;
unsigned int  Distance=0;
unsigned char Rx_DATA[8];
unsigned char CMD[4][6]={
                         {0x55,0xAA,0x11,0x00,0x02,0x12},
                         {0x55,0xAA,0x22,0x00,0x02,0x23},
                         {0x55,0xAA,0x33,0x00,0x02,0x34},
                         {0x55,0xAA,0x44,0x00,0x02,0x45},
                        }; //Distance measurement command packet

void setup() {
  Serial1.begin(19200);  //Communicate with module via Serial1, set baud rate to 19200
  Serial.begin(19200);   //Set Serial to serial port of data output
}

void loop() {
  for(j=0;j<4;j++)
  {
 for(i=0;i<6;i++){
    Serial1.write(CMD[j][i]);
    }
 delay(150);  //Wait for the end of distance measurement
 i=0;
 while (Serial1.available()){  //Read return data package (NOTE: Demo is just for your reference, the data package haven't be calibrated yet)
    Rx_DATA[i++]=(Serial1.read());
    }
 Distance=((Rx_DATA[5]<<8)|Rx_DATA[6]); //Get the distance data
 Serial.print("URM08-RS485[");   //Print distance
 Serial.print(j);
 Serial.print("]get_Dis= ");
 Serial.print(Distance);
 Serial.println("cm");
 Rx_DATA[5] = 0;
 Rx_DATA[6] = 0;
  }
 Serial.print("\r\n\r\n");    //Print (\r\n\r\n);(\r\n\r\n) are new line characters to get better format

 delay(300);  //Wait for the end of distance measurement
}

Detetion Angle and Sensitivity

Normally, the detection area of an ultrasonic sensor is irregular and hard to define due to its physical characteristics. In actual use, we found that the detection area and sensitivity of this sensor may be larger than other ultrasonic sensors. Therefore, when the sensor is used in a narrow space, a non-target object may be detected.

We used two kinds of reference target obstacles to repeatedly test many sample products. The reference detection area of the corresponding target is as follows:

Test on PVC pipe with a diameter of 7.5cm

pvc

Test on smooth flat panel

Plane plate

FAQ

The product supports Modbus-RTU protocol. For any questions, advice or cool ideas to share, please visit the DFRobot Forum

More Documents

URM08 Datasheet