Ultrasonic distance sensor (SR04)
HC-SR04 ultrasonic ranger · 5 V · send a 10 µs pulse on TRIG; ECHO then goes HIGH for 58 µs per cm (out to about 4 m) · ECHO is a 5 V signal: divide it down for a 3.3 V board · target now at 50 cm

Try it on the benchThe lab drops it on an empty bench and opens its datasheet card.
Typical part: HC-SR04 ultrasonic module
Pins
- VCC
- TRIG
- ECHO
- GND
Ratings and limits
| Supply | 5 V, 15 mA |
|---|---|
| Range | 2–400 cm |
| Resolution | ≈ 3 mm |
| ECHO | 5 V logic |
How to use it
Pulse TRIG for 10 µs; the ECHO pulse length is the round trip of the sound: cm = µs ÷ 58. With an ESP32, put a 1 kΩ / 2 kΩ divider on ECHO.
Lessons and builds that use it
- Ultrasonic parking sensor (build)