
📏 HC-SR04 Ultrasonic Distance Sensor — 2cm–400cm Range (5V, Arduino / ESP Compatible)
The HC-SR04 is the classic ultrasonic distance sensor for DIY electronics and IoT projects. Measures distance from 2cm to 400cm (4 metres) with ~3mm accuracy using ultrasonic sound pulses. 4-pin interface (VCC, Trig, Echo, GND). DC 5V powered. Compatible with Arduino, ESP8266, ESP32, Raspberry Pi, ESPHome, and Home Assistant. The go-to sensor for water tank level monitoring, obstacle detection, parking sensors, and robotics.
Ultrasonic distance sensors:
⚡ Key Features
- 2cm–400cm Range — measures distances from 2cm to approximately 4 metres using 40kHz ultrasonic pulses
- ~3mm Accuracy — precise enough for water tank level monitoring, bin level detection, and proximity sensing
- 15° Detection Angle — narrow beam provides focused measurement; minimise interference from walls and obstacles
- Simple 4-Pin Interface — VCC (5V), Trig (trigger pulse input), Echo (distance pulse output), GND
-
ESPHome Built-In Support — ESPHome has a native
ultrasonicsensor platform; define Trig/Echo pins in YAML and get distance readings in Home Assistant instantly -
Arduino / Raspberry Pi — use the
NewPinglibrary (Arduino) orRPi.GPIO(Python) for quick integration - Ultra-Low Cost — the most affordable distance sensor available; stock up for multiple projects
- 5V Logic — outputs 5V on the Echo pin; ESP8266/ESP32 need a voltage divider (e.g. 1kΩ + 2kΩ) on the Echo line
🏠 Perfect For
Water Tank Level (Indoor Tank)
Mount above an indoor JoJo tank or header tank. Measure the distance to the water surface and calculate fill percentage. Alert via Home Assistant when the tank is low or full. For outdoor tanks, use the DYP-A02 waterproof sensor instead.
Robotics & Obstacle Detection
The classic sensor for line-following robots, obstacle avoidance bots, and Arduino-powered rovers. Detect walls and objects up to 4m ahead with a narrow 15° beam.
DIY Parking Sensor
Mount in your garage to display distance as you park. Connect to a D1 Mini with an LED strip — green/yellow/red as you approach the wall. Fun weekend project.
Bin & Hopper Level
Monitor fill level of rubbish bins, grain hoppers, feed bins, or pellet stores. Get alerts when it's time to empty or refill.
🔀 HC-SR04 vs DYP-A02 — Which to Choose?
HC-SR04 (this product) — exposed PCB, NOT waterproof, 5V logic, ultra cheap (R34). Perfect for indoor projects, prototyping, robotics, and learning. Use it anywhere moisture isn't a concern.
DYP-A02 — sealed waterproof housing, 3.3V/5V compatible, 4.5m range. Designed for outdoor water tank monitoring where the sensor is exposed to humidity, condensation, and splashes. Costs more but built for the job.
📋 Technical Specifications
| Product | HC-SR04 Ultrasonic Distance Sensor |
| Model | HC-SR04 |
| Working Voltage | DC 5V |
| Static Current | ~5mA |
| Measurement Range | 2cm – 400cm (~4m) |
| Accuracy | ~3mm (0.3cm) |
| Detection Angle | ≤15° |
| Trigger Pulse | 10µs HIGH on Trig pin |
| Echo Output | 5V HIGH pulse (duration proportional to distance) |
| Interface | 4-pin: VCC · Trig · Echo · GND |
| Frequency | 40 kHz ultrasonic |
| Board Size | ~45 × 20mm |
| Waterproof | No (indoor use only) |
| Compatible With | Arduino · ESP8266 · ESP32 · Raspberry Pi · ESPHome · Home Assistant |
🔗 Pair With
D1 Mini
Flash ESPHome with the ultrasonic sensor platform. Wire Trig/Echo to GPIOs. Tank level or parking sensor reporting to Home Assistant.
View Product →DYP-A02 Waterproof Sensor
Need it outdoors or in a tank? The DYP-A02 is a sealed waterproof ultrasonic sensor with 3.3V/5V support.
View Product →❓ Frequently Asked Questions
Can I use this for an outdoor water tank?
Why does the Echo pin need a voltage divider?
How does it work?
🤝 Need Help? We're Here for You!
Visit Us
8 Wildebraam Street
Weltevreden Park, Roodepoort
Gauteng, 1709
Measure Distance for R34 📏
The most popular ultrasonic sensor in the world — now in your project.