Ultrasonic Sensor (HC-SR04)
The HC-SR04 is a widely used ultrasonic distance sensor that provides non-contact measurement from 2cm to 400cm with high accuracy and stable readings. It is highly popular in robotics and DIY electronics for obstacle avoidance and proximity sensing.
10 in stock
The HC-SR04 is a widely used ultrasonic distance sensor that provides non-contact measurement from 2cm to 400cm with high accuracy and stable readings. It is highly popular in robotics and DIY electronics for obstacle avoidance and proximity sensing.
Description & Working Principle
The sensor operates on the principle of SONAR (Sound Navigation and Ranging), similar to how bats and dolphins navigate. It consists of two ultrasonic transducers: one acting as a transmitter (TX) and the other as a receiver (RX).
-
Triggering: The microcontroller sends a 10µs HIGH pulse to the Trigger (Trig) pin.
-
Emission: Upon receiving this trigger, the sensor automatically emits an 8-cycle burst of ultrasonic sound at 40 kHz.
-
Reception: These sound waves travel through the air, hit an object, and bounce back to the sensor.
-
Echo Output: The Echo pin goes HIGH immediately after the 8-cycle burst is sent and stays HIGH until the reflected sound is received. The duration of this HIGH pulse is directly proportional to the distance of the object.
Characteristics
-
Non-Contact Measurement: Measures distance without physical contact with the object.
-
Measuring Angle: The sensor has a detection cone of approximately 15 to 30 degrees.
-
Stability: Its operation is not significantly affected by sunlight or the color of the target, unlike some infrared sensors.
-
Material Sensitivity: Hard surfaces reflect sound waves best; soft materials like cloth or wool can absorb sound, leading to inaccurate readings.
Operating Parameters
| Parameter | Specification |
| Operating Voltage | 5V DC |
| Operating Current | 15mA |
| Quiescent Current | < 2mA |
| Ultrasonic Frequency | 40 kHz |
| Measuring Range | 2 cm – 400 cm |
| Accuracy / Resolution | ±3 mm |
| Trigger Input Signal | 10µs TTL pulse |
| Echo Output Signal | TTL pulse proportional to distance |
| Dimensions | 45 x 20 x 15 mm |
Calculation Formula:
To calculate the distance in centimeters, you can use the travel time (duration) of the echo pulse:
Or simplified for Arduino code (time in microseconds):
