
HC-SR04 ULTRASONIC SENSOR
Share :
The HC-SR04 is one of the most widely used and recognizable ultrasonic distance sensor modules in DIY electronics, especially popular with Arduino and Raspberry Pi projects. It works on the principle of sonar or echolocation to measure distance.
The sensor determines the distance to an object by measuring the Time-of-Flight (ToF)—the time it takes for a sound wave to travel from the sensor to an object and return.
Trigger (Transmit): Your microcontroller (e.g., Arduino) sends a short 10us HIGH pulse to the TRIG pin.
Emission: The sensor's transmitter instantly emits an 8-cycle ultrasonic sound burst at 40 kHz.
Echo (Receive): The sensor sets the ECHO pin to HIGH immediately after transmission. It remains HIGH while waiting for the sound to return.
Time Measurement: When the sound wave hits an object and bounces back to the receiver, the sensor sets the ECHO pin to LOW.
Distance Calculation: The microcontroller measures the duration of the HIGH pulse on the ECHO pin (Duration). This duration is the round-trip travel time of the sound.
| Parameter | Value |
| Operating Voltage | 5V DC |
| Measuring Range (Practical) | 2cm to approx. 400cm (2cm to 4m) |
| Accuracy | pm 3mm |
| Working Current | < 15mA |
| Measuring Angle | < 15circ cone |
| Ultrasonic Frequency | 40kHz |
The HC-SR04 has a simple 4-pin interface:
| Pin Name | Function | Connection on Arduino UNO |
| VCC | Power Supply | +5V |
| Trig | Trigger Input | Any Digital Output Pin (e.g., Pin 9) |
| Echo | Echo Output | Any Digital Input Pin (e.g., Pin 10) |
| GND | Ground | GND |
Note on Raspberry Pi/3.3V Microcontrollers: The HC-SR04 operates at 5V, and its Echo pin outputs a 5V signal. If you are connecting it to a 3.3V microcontroller (like a Raspberry Pi or ESP32), you must use a voltage divider on the Echo line to prevent damaging the microcontroller.
Robotics: Obstacle detection and avoidance for mobile robots.
Distance Measurement: Non-contact measurement systems.
Home Automation: Liquid level sensing in tanks/bins, smart parking assistants.
Security: Simple motion/proximity detection alarms.

