Figure 5 Connect Sensor to PC via USB-RS485 converter
Figure 6 Connect Sensor to PC via RS232-RS485 Converter
Figure 7 Connect Sensor to Arduino Via MAX485 IC
SensorNetworking
Upto 32 URM04 sensors are able to join a network. Simply serially connect the sensors uses twisted
pair cables. A diagram is illustrated in Figure 7.
Figure 7 URM04 Networking
ArduinosketchfordrivingoneURM04sensor
The sketch code:
/*
# The Sample code for driving single URM04 measuring distance function
# Editor : Lauren
# Date : 2012.2.8
# Ver : 0.3
# Product: URM04 Ultrasonic sensor
# Specification
* Detecting range: 4cm-500cm
* Resolution : 1cm
* Interface : RS485
* Units: Range reported in cm
* Temperature sensor: 12 bits reading from serial port
# Description:
# finish driving single URM function
# if use the IO expansion shield to drive the urm sensors, the measuring rate
may be 20Hz or slower[if you want].
# The sample code is compatible with the Arduino IDE 1.0 and also the earlier
version.
*/
#include "Urm4parser.h"
void setup(){
urmInit(); // Init the URM04 sensor
}
void loop(){
static unsigned long timePoint = 0;
runUrm4(); // Drive URM04 Sensor and transmit the protocol to the sens
or via RS485 interface
// (IO Expansion shield V5 for arduino)
decodeURM4(); // Read and get the distance value from the sensor
if(millis() - timePoint > 100){
PrintData(); // print the data
timePoint = millis();
}
// PrintData();
// delay(100);
}
void PrintData(){
Serial.print("Distance value: ");
for(int i = 0; i < urmAccount; i++){

SEN0002

Mfr. #:
Manufacturer:
DFRobot
Description:
Distance Sensor Modules URM04 v2.0 Ultrasonic Sensor
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet