HC-SR04 Ultrasonic Range Finder Module

Uses sound waves to detect obstacles and measure distance DESCRIPTION The HC-SR04 Ultrasonic Range Finder Module uses...
Vendor: Keszoox
$1.95
$2.55
$1.95

Shipping

The shipping fee depends on your address

Standard: 9-15 business days,fee is down to $3.99

Express: 4-7 business days,fee is down to $5.99

Support Customization

WE'RE READY TO BUILD A CUSTOM PRODUCT FOR YOU.

If you're looking for a custom product, we can help. Kindly contact us via email support@keszoox.com and send us the details for your need, then we'll let you know how we can deliver the right solution.

Built And process your order

We make into production usually Within 1 - 3 Bussiness Days.

Expect customization orders.
HC-SR04 Ultrasonic Range Finder Module

HC-SR04 Ultrasonic Range Finder Module

$2.55 $1.95

HC-SR04 Ultrasonic Range Finder Module

$2.55 $1.95

Uses sound waves to detect obstacles and measure distance

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.

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
  • 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.

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:

  1. The module is normally idle.
  2. 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.
  3. The module emits eight bursts of 40KHz sound and sets it’s ECHO pin output HIGH.
  4. When the signal is reflected back from an object and is detected by the module, the ECHO pin is set back to LOW.
  5. 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 5V.
  • TRIG –   Connect to any digital output pin on uC.  A 10uSec or wider pulse starts a measurement cycle
  • ECHO –  Connect to any digital input pin on uC.  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 uC.

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.

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.

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
 * 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:

  • Sample inspected and tested per incoming shipment.

Notes: 

  1. Active circuitry is on the back of the module, so care should be used to avoid possible electrical shorts.

TECHNICAL SPECIFICATIONS

Maximum Ratings
          Vcc 4.5 – 5.5V  (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

WE'RE READY TO BUILD A CUSTOM PRODUCT FOR YOU.

Contact us:
Support@keszoox.com
What we can help:
If you're looking for a wire or cable assembly, we can help.
What we need your help next:
Kindly contact us via email support@keszoox.com and send us the details fo your need, then we'll let you know how we can deliver the right solution.

Shipping Policy

All orders are dispatched from our warehouse. The shipments are fully tracked—from our door to yours. Please allow 3-5 business days for your order to be processed in addition to the shipping times below.

Shipping Times

Standard: 9-15 business days. Express: 4-7 business days.

Please note that shipping providers are extremely busy during this time, and some orders might experience a delay on top of usual delivery times. If your order is late, please allow 5-10 days more than indicated in standard shipping times before contacting our customer service. Thank you for your understanding.

Tracking

All orders are 100% tracked. You’ll receive an email with a tracking number and a link to track your parcel once your order leaves our warehouse. Please allow 24-48 hours for the tracking link to start showing shipping information.

Related Products

Recently Viewed Products