Grove - Ultrasonic Ranger
Introduction
This Grove - Ultrasonic ranger is a non-contact distance measurement module which works at 40KHz. When we provide a pulse trigger signal with more than 10uS through singal pin, the Grove_Ultrasonic_Ranger will issue 8 cycles of 40kHz cycle level and detect the echo. The pulse width of the echo signal is proportional to the measured distance. Here is the formula: Distance = echo signal high time * Sound speed (340M/S)/2. Grove_Ultrasonic_Ranger’s trig and echo singal share 1 SIG pin.
Warning
Do not hot plug Grove-Ultrasonic-Ranger, otherwise it will damage the sensor. The measured area must be no less than 0.5 square meters and smooth.
Version
Product Version | Changes | Released Date |
---|---|---|
Grove-Ultrasonic ranger V1.0 | Initial | Mar 2012 |
Grove-Ultrasonic ranger V2.0 | Improve the power stability with low-voltage main board with below changes: 1. Added an capacitance C14 2. Redesigned the layout to make it more tidy 3. Compatible with 3.3V voltage system | July 2017 |
Specification
Parameter | Value/Range |
---|---|
Operating voltage | 3.2~5.2V |
Operating current | 8mA |
Ultrasonic frequency | 40kHz |
Measuring range | 2-350cm |
Resolution | 1cm |
Output | PWM |
Size | 50mm X 25mm X 16mm |
Weight | 13g |
Measurement angle | 15 degree |
Working temperature | -10~60 degree C |
Trigger signal | 10uS TTL |
Echo signal | TTL |
Tip
More details about Grove modules please refer to Grove System
Platforms Supported
Getting Started
Play With Arduino
Hardware
- Step 1. Prepare the below stuffs:
Seeeduino V4.2 | Base Shield | Grove - Ultrasonic Ranger |
---|---|---|
![]() |
![]() |
![]() |
Get ONE Now | Get ONE Now | Get ONE Now |
- Step 2. Connect Ultrasonic Ranger to port D7 of Grove-Base Shield.
- Step 3. Plug Grove - Base Shield into Arduino.
- Step 4. Connect Arduino to PC through a USB cable.
Note
If we don’t have Grove Base Shield, We also can directly connect Grove_Ultrasonic_Ranger to Arduino as below.
Seeeduino | Grove-Ultrasonic Ranger |
---|---|
5V | Red |
GND | Black |
Not Conencted | White |
D7 | Yellow |
Software
- Step 1. Download the UltrasonicRanger Library from Github.
- Step 2. Refer How to install library to install library for Arduino.
- Step 3. Copy the code into Arduino IDE and upload.
#include "Ultrasonic.h"
Ultrasonic ultrasonic(7);
void setup()
{
Serial.begin(9600);
}
void loop()
{
long RangeInInches;
long RangeInCentimeters;
Serial.println("The distance to obstacles in front is: ");
RangeInInches = ultrasonic.MeasureInInches();
Serial.print(RangeInInches);//0~157 inches
Serial.println(" inch");
delay(250);
RangeInCentimeters = ultrasonic.MeasureInCentimeters(); // two measurements should keep an interval
Serial.print(RangeInCentimeters);//0~400cm
Serial.println(" cm");
delay(250);
}
- Step 4. We will see the distance display on terminal as below.
The distance to obstacles in front is:
2 inches
6 cm
The distance to obstacles in front is:
2 inches
6 cm
The distance to obstacles in front is:
2 inches
6 cm
Play With Raspberry Pi
Hardware
- Step 1. Prepare the below stuffs:
Raspberry pi | GrovePi_Plus | Grove - Ultrasonic Ranger |
---|---|---|
![]() |
![]() |
![]() |
Get ONE Now | Get ONE Now | Get ONE Now |
- Step 2. Plug the GrovePi_Plus into Raspberry.
- Step 3. Connect Grove-Ultrasonic ranger to D4 port of GrovePi_Plus.
- Step 4. Connect the Raspberry to PC through USB cable.
Software
- Step 1. Follow Setting Software to configure the development environment.
- Step 2. Git clone the Github repository.
cd ~
git clone https://github.com/DexterInd/GrovePi.git
- Step 3. Excute below commands to use the ultrasonic_ranger to meansure the distance.
cd ~/GrovePi/Software/Python
python grove_ultrasonic.py
Here is the grove_ultrasonic.py code.
# GrovePi + Grove Ultrasonic Ranger
from grovepi import *
# Connect the Grove Ultrasonic Ranger to digital port D4
# SIG,NC,VCC,GND
ultrasonic_ranger = 4
while True:
try:
# Read distance value from Ultrasonic
print ultrasonicRead(ultrasonic_ranger)
except TypeError:
print "Error"
except IOError:
print "Error"
- Step 4. We will see the distance display on terminal as below.
pi@raspberrypi:~/GrovePi/Software/Python $ python grove_ultrasonic.py
9
9
9
9
9
9
9
9
9
9
9
FAQs
Please click here to see all Grove-Ultrasonic Ranger FAQs.
Tech Support
Please do not hesitate to contact techsupport@seeed.cc if you require further information.
Resources
- [PDF] Download Wiki PDF
- [PDF] Grove_Ultrasonic Ranger Schematic
- [Library] Grove_Ultrasonic Ranger library
- [Project]The Color Helix
- [Project]Indoor Lightning Cloud
- [Project]Automatic Water Level Controller
- [Example] Example_Measure_distance_and_led_display
- [Example] Example_Measure_and_display_the_distance
Arduino | Wio | BeagleBone | Raspberry Pi | LinkIt ONE |
---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
Caution
The platforms mentioned above as supported is/are an indication of the module's hardware or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.
Help us make it better
Welcome to the new documentation system of Seeed Studio. We have made a lot of progress comparing to the old wiki system and will continue to improve it to make it more user friendly and helpful. The improvement can't be done without your kindly feedback. If you have any suggestions or findings, you are most welcome to submit the amended version as our contributor via Github or give us suggestions in the survey below, it would be more appreciated if you could leave your email so that we can reply to you. Happy Hacking!