HC-SR04 Ultrasonic Sensor Specifications and Features - Complete Guide
Detailed HC-SR04 specs, timing formulas, wiring diagrams and South African buying notes. Learn calculations, troubleshooting and classroom tips.

Timing-to-Distance
Use t_echo/58 for cm; adjust for temperature when precision matters.
Wiring Tips
Power at 5 V; use level shifting for 3.3 V GPIOs like Raspberry Pi.
Practical Constraints
Surface reflectivity, angle and cross-talk affect effective range.
Overview of the HC-SR04
The HC-SR04 is a low-cost ultrasonic distance sensor commonly used in hobby, education and prototyping projects. It uses ultrasonic pulses (40 kHz) to measure distance by timing the echo return. This guide breaks down key specifications, electrical requirements, timing formulas, wiring examples, and practical South African considerations for sourcing and using the HC-SR04 in maker and educational projects.
Key specifications
| Parameter | Typical Value | Notes |
|---|---|---|
| Operating Voltage | 5 V DC | Logic-level trigger and echo around 5 V |
| Operating Frequency | 40 kHz | Standard ultrasonic frequency for obstacle detection |
| Range (typical) | 2 cm - 400 cm | Effective range depends on target size and reflectivity |
| Resolution | ~3 mm (theoretical) | Limited by timing granularity and noise |
| Trigger Pulse | 10 us TTL pulse | Pulse starts measurement cycle |
| Echo Output | Pulse width proportional to distance | Measure pulse width to compute range |
How the HC-SR04 measures distance
Operation sequence: the microcontroller sends a 10 us high pulse to TRIG. The module emits an ultrasonic burst (~8 cycles at 40 kHz) and sets ECHO high. ECHO stays high until the echo is received; pulse width (t_echo) is proportional to the round-trip time of sound.
Convert t_echo to distance using the speed of sound (approximately 343 m/s at 20 degreesC). Basic formula:
distance (m) = (t_echo (s) * speed_of_sound (m/s)) / 2
Commonly used simplified formula in centimetres:
distance (cm) = t_echo (us) / 58
(Note: using speed_of_sound = 343 m/s gives t_echo/58; changes in ambient temperature affect the constant.)
Temperature correction
Speed of sound varies with air temperature: c ~ 331.4 + 0.6 * T (m/s), where T is degreesC. For accurate work in South African conditions (e.g., 5 degreesC to 35 degreesC), adjust calculations accordingly. For wiring examples and an Arduino integration walkthrough, see tutorial on integrating HC-SR04 with Arduino.
If you need sourcing options within South Africa, check buy BMT ultrasonic sensor HC-SR04 online in South Africa for local purchase guidance.
For common problems like false echoes, noisy readings, or wiring mistakes, refer to troubleshooting common issues with HC-SR04 sensors.
Related Sensors & Semiconductors Products
Discover quality sensors & semiconductors products related to HC-SR04 Ultrasonic Sensor Specifications and Features - Complete Guide
Dfrobot Sen0114 Arduino Compatible Soil Moisture Sensor
Dfrobot Sen0114 Arduino Compatible Soil Moisture Sensor
Rfid Contactless Smart Reader & Writer - 13.56mhz Nfc Acr122u
Rfid Contactless Smart Reader & Writer - 13.56mhz Nfc Acr122u
Unassembled Diy Heatsink And Fan Cooler Kit For Use With A Thermoelectric Peltier Module
Unassembled Diy Heatsink And Fan Cooler Kit For Use With A Thermoelectric Peltier Module
Sen0098 Arduino Interface Ac/dc Hall Effect Current Sensor 50a
Sen0098 Arduino Interface Ac/dc Hall Effect Current Sensor 50a
Ir Obstacle Avoidance Sensor Module - 2~4cm Detection Range
Ir Obstacle Avoidance Sensor Module - 2~4cm Detection Range
Am2301 Digital Temperature & Humidity Sensor
Am2301 Digital Temperature & Humidity Sensor
Mini Camera Module For Raspberry Pi - 5mp, 1080p Video, Tiny Board
Mini Camera Module For Raspberry Pi - 5mp, 1080p Video, Tiny Board
Sw-420 Arduino Compatible Digital Vibration Sensor Module Using Lm393 Comparator
Sw-420 Arduino Compatible Digital Vibration Sensor Module Using Lm393 Comparator
Wiring and example code snippets
Typical HC-SR04 pinout: VCC, TRIG, ECHO, GND. VCC is 5 V. Microcontroller GPIOs must tolerate 5 V on the echo pin; if using 3.3 V devices (many Raspberry Pi or some MCUs), use a level shifter or simple resistor divider on ECHO.
Simple wiring ASCII diagram
+5V ----- VCC (HC-SR04) GND ----- GND (HC-SR04) GPIOx ----- TRIG (HC-SR04) GPIOy <---- ECHO (HC-SR04) [use level shifting for 3.3V GPIOs]
Arduino timing example (concept)
1. Set TRIG LOW for 2 us. 2. TRIG HIGH for 10 us. 3. Read pulse width on ECHO (pulseIn). 4. distance_cm = pulseWidth / 58.0.
Practical selection and troubleshooting
- Surface and angle: small or soft targets (cloth, foam) reflect poorly; aim perpendicular to the surface for best results.
- Minimum range: objects closer than ~2 cm may not be detected reliably.
- Interference: avoid using multiple HC-SR04 modules simultaneously without synchronization, as echoes can cross-talk.
- Power supply: use a stable 5 V source; noisy supply can cause false readings.
- Pulse timing: ensure microcontroller timers and blocking delays are appropriate for your sampling rate.
Example calculations with South African context
Example: at 25 degreesC, speed of sound ~ 331.4 + 0.6*25 = 346.4 m/s. If measured t_echo = 11600 us (0.0116 s):
distance = 0.0116 * 346.4 / 2 ~ 2.010 m (201 cm)
If using the simple divider: 11600 us / 58 ~ 200 cm (close to corrected value).
Local buying and classroom use notes (South Africa)
Communica stocks a range of ultrasonic modules, sensors and related prototyping accessories in categories such as Sensors & Semiconductors and Robotics & Prototyping. For students and educators: order quantities for labs may incur lead times; check branch stock at Samrand, Pretoria CBD or Cape Town for collection. Prices and availability in ZAR vary; typical hobby HC-SR04 modules are low-cost but buying genuine modules or branded sensor breakout boards can improve reliability.
Consider using sensor shields, header-mounted level shifters or dedicated 3.3 V-compatible ultrasonic modules when integrating with Raspberry Pi or 3.3 V MCUs to protect GPIOs.
Troubleshooting checklist
- No echo: confirm VCC/GND and TRIG pulse is reaching module; check with scope or logic probe.
- Spurious readings: add median filtering or take several samples and average; check for nearby reflective surfaces.
- Incorrect range on Pi: ensure ECHO is reduced to 3.3 V using voltage divider or level shifter.
- Cross-talk in multi-sensor arrays: stagger measurement times or use shielding/enclosures.
Sources
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.
Frequently Asked Questions
Get answers to common questions about Sensors And Semiconductors
Why Choose Communica?
*Free Shipping
Free shipping for orders over ZAR 1,000.00.
7-Day Returns
Get a full refund if you had the product for less than 7 days.
Quick Delivery
Nationwide delivery within 2 - 4 working days.
























