Loading your content...
Discover practical uses, wiring, calculations and troubleshooting for HC-SR04 ultrasonic sensors-tips for South African makers, students and engineers.

Ideal for robotics, level sensing and proximity alerts in hobbyist and education projects.
Simple 4-pin wiring with Arduino/ESP and basic filtering improves reliability.
Check branch stock, pickup options and compare sensors on Communica's site.
The HC-SR04 ultrasonic sensor is a low-cost, widely used distance sensor that measures range by sending an ultrasonic pulse and timing the echo. South African makers and students often choose it for robotics, obstacle detection, level measurement and simple proximity alerts because it balances affordability, ease of use and reasonable accuracy for many hobbyist and educational applications. This guide explains best applications for HC-SR04 ultrasonic sensors, selection criteria, wiring examples, simple calculations and troubleshooting tuned to local supply and classroom/industry contexts.
Typical HC-SR04 specs you will see in datasheets and product pages include an operating range of about 2 cm to 400 cm, a supply voltage of 5 V, and a minimum pulse width / timing resolution that translates to centimetre-level resolution in quiet environments. Real-world accuracy depends on target surface, angle, temperature and acoustic noise. When planning a project, expect effective performance within 2-300 cm for reliable readings in indoor settings.
| Feature | HC-SR04 (typical) | Laser/Time-of-Flight |
|---|---|---|
| Range | ~2-400 cm | ~1 cm-40 m (model dependent) |
| Typical accuracy | ±1-3 cm (ideal) | ±0.1-1 cm |
| Cost (estimate) | Low (ZAR 30-120 depending on source) | Medium-High (ZAR 200-2000+) |
For local availability and to compare brands and modules, visit Communica's collections page Shop by Category or see the full product index All Products. If you need company background or branch pickup options for faster local collection, check Communica's About page About Us.
HC-SR04 uses four pins: VCC (5 V), Trig (input), Echo (output) and GND. Many microcontrollers (Arduino, ESP32 with level shifting) work well. Below is a common wiring pattern for an Arduino Uno.
Arduino HC-SR04 5V -> VCC GND -> GND Digital D2 -> Trig Digital D3 <- Echo
If using a 3.3 V MCU like some ESP32 boards, use a simple voltage divider on Echo or a logic-level shifter to avoid exposing the MCU input to 5 V. For code examples and libraries, the Communica collections page lists compatible development boards and modules Shop by Category.
Use the echo time to calculate distance with the speed of sound (~343 m/s at 20°C). The basic formula is:
distance (m) = (time_of_echo (s) × speed_of_sound) / 2
For microcontroller timers reporting microseconds:
distance (cm) = (time_us / 2) / 29.1
1) Obstacle avoidance for mobile robots: HC-SR04 modules are commonly mounted at the front or on servo-mounted turrets to detect obstacles and trigger avoidance behaviours. Use filtering (median or moving average) to reduce spurious readings from uneven surfaces.
2) Water/Liquid level sensing (open tanks): Mounted above the liquid surface, an HC-SR04 can monitor level changes. Account for foam, turbulence and surface inclination. For sealed or foamy tanks consider alternative sensors if ultrasonic reflection is inconsistent.
3) Parking aids and proximity alerts: In garages or small workshops, HC-SR04 provides a simple visual/audible cue for stopping distance. Combine with LEDs or buzzers and calibrate stopping thresholds in ZAR-based local testing environments.
Example: A university robotics team in Pretoria building an obstacle-avoiding rover. Use two HC-SR04 sensors (front and side) on buffered digital pins, apply a 5-sample median filter, and implement a 200 ms timeout per measurement to keep control loops responsive. Local stock commonly allows quick replacement-check stock in Samrand or branch pickup options via Branches & Trading Hours.
Example: A maker in Cape Town prototyping a countertop liquid level indicator. Budget for 2-3 modules for testing surface response; estimated component cost is ZAR 30-120 per module depending on supplier and pack size. See available development kits and sensors on the Communica shop by brand page Shop by Brand.
ASCII wiring diagram for multiple sensors on an Arduino (shared GND and 5 V):
Arduino 5V -----+--------------------+----
| |
VCC(S1) VCC(S2)
Arduino GND ---+--------------------+----
| |
GND(S1) GND(S2)
D2 -> Trig(S1) D4 -> Trig(S2)
D3 <- Echo(S1) D5 <- Echo(S2)
Choose laser/ToF sensors for millimetre accuracy, long-range measurements or small-target detection. For dusty, foamy or very noisy acoustic environments, evaluate non-acoustic methods. Use the Communica collections index to compare sensor types and component options comparison of bmt ultrasonic sensor hc-sr04 with other sensors.
Communica supplies semiconductors and electronic components to industries such as automotive, electrical, automation, mining, and education.
Disclaimer: This content is for educational purposes only. Product availability, pricing, and specifications are subject to change. Always verify current details on the retailer's website before making a purchase. We may earn affiliate commissions from qualifying purchases.
Free shipping for orders over ZAR 1,000.00.
Get a full refund if you had the product for less than 7 days.
Nationwide delivery within 2 - 4 working days.
Get answers to common questions about Sensors And Semiconductors