Introduction

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

This new URM08-RS485 Waterproof Sonar Range Finder produced by DFRobot is an ultrasonic distance sensor that designed for professional industry controls and robotic controls. It combines temperature measurement to distance measurement, providing internal temperature compensation, which means better accuracy of distance measurement. Temperature compensation could avoid deviation caused by the change of ambient temperature(Ultrasound v.s Temperature). The internal is completely sealed and the crust is made of metal material, IP67 waterproof, anti-dust and non-corrosive. It can be widely applied to detections of different liquid levels, levels and all kinds of obstacle avoidance applications. Even be immersed in water for a while, It can back to work once be dried. The sensor adopts high standard device selections, guaranteeing narrower blind area and wider distance measurement range. Besides stable data output, it performs excellent in detection and surpasses majority similar products in the market.

URM08-RS485 Waterproof Sonar Range Finder adopts RS485 communication interface and it is compatible with Modbus communication agreement and supports cascade control. It is suitable for industrial control and specialized in applications like water level monitor and robotic obstacle avoidance and so on.

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:

Tutorial (Single URM08-RS485)

Requirements

Connection Diagram

URM08-RS485 Connection Diagram

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

Tutorial 1 Distance Measurement

SEN0246 Distance Measurement Example

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 Distance 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 at here)
 Serial.print(temperature/10);             //Print temperature
 Serial.print('.');
 Serial.print(temperature%10);
 Serial.println("C");
}

Tutorial (Multiple URM08-RS485s)

SEN0246_Multiple URM08-RS485s Connection Diagram SEN0246_Multiple URM08-RS485s Distance Measurement Example

/**************************************************************************************************************
*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
}

More Documents

DFshopping_car1.png Get [Product link Product Name] from DFRobot Store or DFRobot Distributor.