Introduction
This is a non-contact ultrasonic ranging sensor of high-performance from URM09 series, employing standard PH2.0-3P Gravity vertical interface. It provides an accuracy of 1% within an effective measuring range of 2~500cm(test on a flat wall). Similar to SR04 ultrasonic ranging modules in principle and using method, the ranging function of this sensor is triggered by high/low level output from the I/O ports of a host, and then the sensor converts ultrasonic flight time into a high pulse to output. The difference is that the sensor multiplexes input and output signals onto one signal port, which allows users to easily use the sensor for distance measurement only by one I/O port of a controller. Meanwhile, the adoption of advanced hardware and software design ensures excellent and reliable measuring performance. The module works well with 3.3V/5V controllers like Arduino, Raspberry Pi, etc.
With features of small size, high accuracy, plug-and-play and wide measuring range, this module is applicale to an extensive range of applications, such as, robot obstacle avoidance, car backing annunciator, doorbell, metro safety line warning, etc.
Specification
- Operating Voltage: 3.3~5.5V DC
- Max Instantaneous Working Current: <20mA
- Operating Temperature Range: -10℃~+70℃
- Effective Ranging Range: 2cm~500cm
- Resolution: 1cm
- Accuracy: 1%
- Acoustic Frequency: 40±2KHz
- Ranging Frequency: 25Hz Max
- Dimension: 47×22mm/1.85×0.87”
Measuring Angle
Board Overview
Num | Label | Description |
---|---|---|
1 | - | Ground |
2 | + | Power Input(3.3V-5.5V) |
3 | D | Digital IO(TRIG/ECHO multiplexing, internally pulled-down) |
Tutorial
Hardware Connection
Connect the sensor to your Arduino mainboard with a Gravity 3Pin digital sensor cable.
Timing Diagram
URM09 Ultrasonic Sensor(Gravity Trig) uses digital IO port to trigger distance measurement, and the tringger signal and received signal shares one pin by TMD(Time Division Multiplexing):
The sensor is in input mode at this time, and the host needs to be set to output mode. Send 10us high pulse trigger signal from the host, and then change the host port status to input, wait for the sensor to return signal.
The output high-level time of the sensor is equal to ultrasonic flight time(longest pulse width time: 35000us).
Arduino Programming
The mainboard outputs a high-level about tens of microseconds to trigger the sensor to start ranging. Then, the sensor will output a high-level pulse proportional to the ultrasonic flight time. The distance can be easily obtained after a simple calculation by detecting high-level time.
Requirements
- Hardware
- DFRduino UNO R3 (or similar) x 1
- URM09 Ultrasonic Sensor(Gravity Trig) x1
- Gravity 3Pin digital sensor cable x1
- Software
Sample Code
/*!
This example is the ultrasonic distance measurement of the module.
Copyright [DFRobot](http://www.dfrobot.com), 2020
Copyright GNU Lesser General Public License
version V1.0
date 29/10/2020
*/
#define VELOCITY_TEMP(temp) ( ( 331.5 + 0.6 * (float)( temp ) ) * 100 / 1000000.0 ) // The ultrasonic velocity (cm/us) compensated by temperature
int16_t trigechoPin = 11;
uint16_t distance;
uint32_t pulseWidthUs;
void setup() {
Serial.begin(9600);
delay(100);
}
void loop() {
int16_t dist, temp;
pinMode(trigechoPin,OUTPUT);
digitalWrite(trigechoPin,LOW);
digitalWrite(trigechoPin,HIGH);//Set the trig pin High
delayMicroseconds(10); //Delay of 10 microseconds
digitalWrite(trigechoPin,LOW); //Set the trig pin Low
pinMode(trigechoPin,INPUT);//Set the pin to input mode
pulseWidthUs = pulseIn(trigechoPin,HIGH);//Detect the high level time on the echo pin, the output high level time represents the ultrasonic flight time (unit: us)
distance = pulseWidthUs * VELOCITY_TEMP(20) / 2.0;//The distance can be calculated according to the flight time of ultrasonic wave,/
//and the ultrasonic sound speed can be compensated according to the actual ambient temperature
Serial.print(distance, DEC);
Serial.println("cm");
delay(500);
}
Expected Results
Programming on MakeCode
- Open MakeCode online editor. Website: https://makecode.microbit.org
- Load URM09_Trig Makecode Library.
- Program as below:
- Compile and burn codes into your micro:bit.
- Check data on serial assistant.
FAQ
For any questions, advice or cool ideas to share, please visit the DFRobot Forum.