HC-SR04 Ultrasonic Distance Sensor for Arduino
The HC-SR04 measures distance from 2cm to 400cm using 40kHz ultrasonic pulses and a time-of-flight calculation. Trigger the sensor with a 10-microsecond pulse on the TRIG pin, and the ECHO pin returns a high pulse whose width in microseconds divided by 58 gives the distance in centimetres. No library is strictly required — a few lines of Arduino code handle the timing — though the NewPing library adds median filtering and non-blocking measurement for cleaner readings.
- 2cm–400cm measurement range
- 3mm resolution
- 5V supply, 2-pin measurement interface — TRIG and ECHO on any digital pins
- 15° cone angle — narrow beam reduces false reflections
- No library required — simple pulse timing in Arduino code
| Specification | Value |
|---|---|
| Range | 2cm – 400cm |
| Resolution | 3mm |
| Frequency | 40kHz ultrasonic |
| Beam angle | 15° |
| Supply voltage | 5V DC |
| Current | 15mA during measurement |
Can you use HC-SR04 with a 3.3V Arduino or ESP32?
The HC-SR04 needs a 5V supply and outputs a 5V ECHO signal. On a 3.3V ESP32, connect VCC to 5V, divide the ECHO pin to 3.3V with a 1k/2k resistor divider, and connect TRIG directly — ESP32’s 3.3V output is high enough to trigger the sensor. Without the voltage divider, the 5V ECHO signal risks damaging the ESP32’s GPIO.
What surfaces does it struggle to measure?
The HC-SR04 under-reads on soft, angled, or very small surfaces that scatter ultrasound rather than reflecting it back toward the sensor. Foam, fabric, and thin objects at 45° angles give erratic readings. Flat hard surfaces at 90° give the most consistent results.
Best for
Obstacle avoidance robots, bin level monitors, parking distance sensors, liquid level gauges, automatic hand-wash triggers, alarm perimeter sensors, and classroom distance measurement experiments.
Why Kunkune
Shipped from UK stock. 60-day returns, no minimum order. Fast Royal Mail delivery.
Buying in bulk? For orders of 10+ units, contact us for trade pricing.

















