Description
The HC-SR04+ Ultrasonic Range Finder Module uses ultrasonic sound waves to detect the presence of and measure the distance to objects in front of it. It is the same as the standard HC-SR04 module except that it can also be operated at 3.3V for direct connection to 3.3V MCUs.
PACKAGE INCLUDES:
- HC-SR04+ Ultrasonic Range Finder Module
KEY FEATURES OF HC-SR04+ ULTRASONIC RANGE FINDER MODULE:
- 2 cm -400 cm (13 feet) detection range
- 40 kHz operation
- ±15 degree field of view
- 3.3 & 5V logic compatible
- 3.3 & 5V operation
The detection and measurement range is from 2 cm up to 400 cm which is about 13 feet with a stated accuracy of +/- 3mm. The ultrasonic sound is pulsed at 40 kHz and is not audible to the human ear. When operated at lower voltages, the maximum distance will be a little shorter.
These modules are commonly used on robotic vehicles for obstacle detection and avoidance. Because they use sound waves for detection, they are not sensitive to light sources or optically reflective surfaces like IR can be. In addition, by using sound instead of light, it is possible to measure the time that it takes for the sound to be echo’d back and therefore the distance to the object can be calculated with a fair amount of accuracy which can be quite handy.
These modules have a ‘view’ of about 30 degrees, so they are sometimes mounted to a servo motor so that the sensor can ‘look-around’ at its surroundings. The fact that the sensors look like a couple of eyes adds to the cool factor as well.
The way the HC-SR04+ Ultrasonic Range Finder Module works is as follows:
- The module is normally idle.
- A 10 uSec or wider pulse is sent to the TRIG pin on the module, usually by a microcontroller. This will cause the module to start a detection cycle.
- The module emits eight bursts of 40KHz sound and sets it’s ECHO pin output HIGH.
- When the signal is reflected back from an object and is detected by the module, the ECHO pin is set back to LOW.
- By measuring the amount of time that the ECHO pin is held HIGH, the distance to the object can be calculated using the basic formula (Time that ECHO is held HIGH * Speed of sound / 2) The divide by 2 is because the sound has to travel in both directions (both out and back) and we want to know just the out distance.
If an echo is not returned (no object detected), the module will still lower the ECHO pin after a fixed delay. This delay may vary, but is about 200mSec on the modules that I have measured. This is required to prevent the module from hanging if there is no return echo. If you run the test software shown down below and then block the sensor with your hand , you will see what is returned when no obstacle is detected. This is typically something along the lines of 75 feet. To be safe, it is generally best to assume that any reading over about 13 feet is the same as no obstacle being detected.
Module Connections:
There is a 4-pin header on the assembly. The GND pin is connected to the system ground and the Vcc pin is connected to 5V. The TRIG pin is an input pin on which a 10uSec pulse is applied to start the measurement cycle. The ECHO pin is an output pin that is held HIGH for the duration of the time from when the module sends a 40KHz pulse out until it receives the echo back.
1 x 4 Header
- VCC – Connect to 3.3 or 5V to match MCU.
- TRIG – Connect to any digital output pin on MCU. A 10uSec or wider pulse starts a measurement cycle
- ECHO – Connect to any digital input pin on MCU. This pin is held high for the duration of the the measurement cycle.
- GND – Connect to system ground. This ground needs to be in common with the MCU.
OUR EVALUATION RESULTS:
This is a commonly used module for obstacle detection and basic range finding. These are much more capable than the basic IR obstacle avoidance sensors that come in most sensor kits and are highly recommended if you are building a motorized robotic car and want to implement a nicely capable obstacle avoidance system or just want to measure distance for some other reason. The module has a built-in small microprocessor which does all the heavy lifting of managing the ultrasonic sensors.
The main advantage of this module over other ultrasonic modules is that that it can be operated down to 3V and so will work directly with 3.3V MCUs.
An optional HC-SR04 Ultrasonic Distance Measurement Control module is also available. This module takes care of controlling the sensor and has a 3-digit 7-segment display to show the distance in centimeters without the need for using a separate MCU which may be handy for some applications. This module operates at 5V.
If you want to upgrade a little, the HY-SRF05 has a little better accuracy and distance but otherwise is very similar and is software compatible. It does have 5 pins instead of 4, though only 4 are used.
If you want to upgrade another notch, the US-100 is a similar sensor module that can operate in ping mode like the HC-SR04+, but which optionally takes care of the echo timing and temperature measurement for you and provides the computed distance data through a serial interface.
The program below implements a basic setup where the measured range is displayed in centimeters, inches and feet. Since the speed of sound varies with the temperature, for maximum accuracy the temperature can be measured and used in the calculation, so this is broken out in the code below but defaults to 20C. It would be straight forward for instance to implement a DS18B20 or LM35 temperature sensor so that the actual temperature can be measured and used in the calculation.
HC-SR04+ Ultrasonic Range Finder Module Program
/* * HC-SR04+ Test * * Exercises the ultrasonic range finder module and prints out the current measured distance * VCC - connect to 5V or 3.3V to match MCU * GND - connect to ground * TRIG - connect to digital pin 12. Can be any digital pin * ECHO - connect to digital pin 13. Can be any digital pin */ const int TRIG_PIN = 12; const int ECHO_PIN = 13; float temp_In_C = 20.0; // Can enter actual air temp here for maximum accuracy or read with sensor float speed_Of_Sound; // Calculated speed of sound based on air temp float distance_Per_uSec; // Distance sound travels in one microsecond at that temp //=============================================================================== // Initialization //=============================================================================== void setup() { pinMode(TRIG_PIN,OUTPUT); pinMode(ECHO_PIN,INPUT); // Formula to calculate speed of sound in meters/sec based on temp speed_Of_Sound = 331.1 +(0.606 * temp_In_C); // Calculate the distance that sound travels in one microsecond in Centimeters distance_Per_uSec = speed_Of_Sound / 10000.0; Serial.begin(9600); } //=============================================================================== // Main //=============================================================================== void loop() { float duration, distanceCm, distanceIn, distanceFt; digitalWrite(TRIG_PIN, HIGH); // Set trigger pin HIGH delayMicroseconds(10); // Hold pin HIGH for 10 uSec digitalWrite(TRIG_PIN, LOW); // Return trigger pin back to LOW again. duration = pulseIn(ECHO_PIN,HIGH); // Measure time in uSec for echo to come back. // convert the time data into a distance in centimeters, inches and feet duration = duration / 2.0; // Divide echo time by 2 to get the time for the sound to travel in one direction distanceCm = duration * distance_Per_uSec; distanceIn = distanceCm / 2.54; distanceFt = distanceIn / 12.0; if (distanceCm <= 0){ Serial.println("Out of range"); } else { Serial.print(duration, 0); Serial.print("uSec, "); Serial.print(distanceCm, 0); Serial.print("cm, "); Serial.print(distanceIn,0); Serial.print("in, "); Serial.print(distanceFt,1); Serial.print("ft, "); Serial.println(); } delay(1000); // Delay between readings }
The board has a 4 small holes that can be used for mounting if desired. There is also a plastic holder available to mount the module as shown below.
BEFORE THEY ARE SHIPPED, THESE MODULES ARE:
- Inspected
- Basic obstacle detection and range finding operation verified
- Packaged in a high quality resealable ESD bag for protection and easy storage.
Notes:
- Active circuitry is on the back of the module, so care should be used to avoid possible electrical shorts.
- PCB may have HC-SR04+ silkscreened on it or have a separate ‘+’ sticker.
Technical Specifications
Maximum Ratings | ||
Vcc | 3.0 – 5.5V (3.3 or 5V typical) | |
IMax | Maximum Current Draw | <15 mA |
Operating Ratings | ||
Frequency | Detector Center Frequency | 40 kHz |
Trigger | Pulse Width | >= 10uSec |
Detection Distance | 2 cm – 400 cm | |
Measurement Resolution | 3 mm (typical) | |
Detection Angle | ± 15 degrees | |
Dimensions | L x W (PCB) | 45 x 21 mm (1.77 x 0.8″) |
Dia x H (Ultrasonic Sensors) | 16 x 12 mm (0.62 x 0.47″) | |
Country of Origin | China |