HC‑SR04 Ultrasonic Sensor: How It Works and Key Applications
The HC‑SR04 ultrasonic sensor is a compact, non‑contact device that uses a transmitter and receiver to measure distance. By timing the echo of a 40 kHz pulse, it calculates the distance to an object with high precision. Its operating range spans from 2 cm to 400 cm, making it ideal for robotics, automation, and hobbyist projects.
Pin Configuration
- Vcc – 5 V power supply.
- Trigger – Input pin. A 10 µs high pulse initiates a measurement.
- Echo – Output pin. Goes high for the time the ultrasonic pulse travels to the target and back.
- GND – Ground connection.
Key Features
- Power: 5 V DC, operating current 15 mA, quiescent <2 mA.
- Dimensions: 45 mm × 20 mm × 15 mm.
- Measurement range: 2 cm to 800 cm (practical 2–400 cm).
- Resolution: 0.3 cm, accuracy ±3 mm.
- Firing angle: 30° (effective <15°).
- Frequency: 40 kHz.
How It Works
The HC‑SR04 operates on the time‑of‑flight principle. When the Trigger pin receives a 10 µs high pulse, the sensor emits eight cycles of 40 kHz sound. The Echo pin rises when the reflected pulse returns. The time between trigger and echo, divided by two, gives the distance:
S = (V × t)/2
where S is distance, V is speed of sound (≈343 m/s at 20 °C), and t is round‑trip time.
Connecting HC‑SR04 to an Arduino

Typical wiring:
- Vcc → 5 V (Arduino)
- Trig → Digital pin 11
- Echo → Digital pin 12
- GND → GND (Arduino)
pulseIn() function to read the Echo pulse width and calculate distance.
Common Applications
- Obstacle detection and avoidance in robots.
- Distance measurement for robotics, drones, and autonomous vehicles.
- Level sensing in tanks and containers.
- Touchless controls and gesture recognition.
- Proximity alarms for security systems.
- Non‑destructive testing and depth profiling.
- Medical ultrasonography and imaging (in specialized configurations).
- Industrial automation and process control.
- Educational projects and STEM learning.
In summary, the HC‑SR04 delivers reliable, accurate distance sensing using simple hardware and firmware. Its low cost and ease of integration make it a staple in both hobbyist and professional projects.
Sensor
- How Distance Sensors Work and Their Key Applications
- Understanding the AD8232 ECG Sensor: Functionality and Applications
- Voltage Sensors: How They Work & Key Applications in Modern Power Systems
- Lambda (Oxygen) Sensor: Function, Operation, and Key Automotive Applications
- Image Sensors: Types, Operation, and Practical Applications
- Gyroscope Sensors: How They Work and Their Key Applications
- Flame Sensors: How They Work and Key Applications in Fire Safety
- Sound Sensors: How They Work & Practical Applications
- Humidity Sensors: How They Work and Key Applications
- Rain Sensors Explained: How They Work & Key Applications