OHMYARD

DISCOVER  ·  EXPERIMENT  ·  BUILD

TRACK 7 · ESP32, PI & ARDUINO APPS28/30
NOV 27, 2026
14:20:00
TRHC-SR04 (40 kHz)45 cm✅ Distance 45 cm · Echo 2624 µs · Safe Logic (3.3V Divided)
Drag or WASD to pan · Q / E to rotate · Scroll to zoom

HC-SR04 Ultrasonic Distance Sensor & 3.3V Echo Divider Lab — Engineering Notes & Troubleshooting

✓ Reviewed by Jason Guo (OhmYard Lab)· IEC & Datasheet Verified· Updated Nov 27, 2026
QUICK ENGINEERING ANSWER (TL;DR)

Send a 10 µs TRIG pulse to fire eight 40 kHz ultrasonic chirps and measure how many microseconds ECHO stays HIGH to compute distance! Critical Warning: HC-SR04 outputs 5 V on ECHO — add a 1 kΩ + 2 kΩ voltage divider when wiring to a 3.3V ESP32 or Raspberry Pi!

d (cm) = (t_echo_µs × 0.0343) ÷ 2 | t_echo ≈ d_cm × 58.3 µs

Blind zone is < 2 cm (ringing overwhelms receiver); maximum reliable range is ~400 cm on flat hard surfaces.

SymbolComponentReal-World Engineering Tip
US1HC-SR04 40 kHz Ultrasonic ModuleSpeed of sound shifts slightly with air temperature: c ≈ 331.3 + 0.606 × Temp(°C) m/s.

Real-World Bench Scenario: Obstacle-Avoiding Robot & Smart Water Tank Level Monitor: pair HC-SR04 with an ESP32 (plus 1kΩ/2kΩ echo divider) and a waterproof JSN-SR04T probe outdoors!

Bench Challenge: Board Switch Test: Switch controller to 'ESP32 / Raspberry Pi (3.3V)' with Echo Divider OFF to trigger the 5V GPIO Over-Voltage Hazard, then enable the 1kΩ+2kΩ divider!

Frequently Asked Questions

Why does my HC-SR04 always return 0 cm?

Usually `pulseIn(ECHO, HIGH, 30000)` timed out because TRIG and ECHO wires are swapped, VCC is connected to 3.3V instead of 5V (standard HC-SR04 won't fire on 3.3V!), or the obstacle is angled away from the receiver.

Continue Exploring Related 2.5D Labs
27. SG90 Servo PWM →29. Opto Relay Module →30. 3.3V ⇄ 5V Shifter →

OHMYARD · ALL 30 INTERACTIVE LABS & SIMULATORS

1. Closed Loop & Faults
/closed-loop
2. Ohm's Law & Thermal
/ohm-law
3. Series vs Parallel
/series-parallel
4. X-Ray Breadboard
/breadboard-simulator
5. LED Resistor & E24
/led-resistor-calculator
6. Voltage Divider & Load
/voltage-divider
7. Multimeter Trainer
/multimeter-simulator
8. RC & Oscilloscope
/rc-oscilloscope
9. 555 Timer Pulse Lab
/555-timer
10. Diode & Rectifier
/diode-rectifier
11. Transistor & Flyback
/transistor-switch
12. PWM Dimmer & Fan
/pwm-dimmer
13. Op-Amp Comparator
/opamp-comparator
14. H-Bridge & Shoot-Through
/h-bridge-motor
15. Buck vs LDO Power
/buck-converter
16. Digital Logic Gates
/logic-gates
17. Resistor Color Code
/resistor-color-code
18. ESP32 Pinout Guide
/esp32-pinout
19. Arduino Uno Pinout
/arduino-uno-pinout
20. Zener Voltage Clamp
/zener-diode-regulator
21. I2C Pull-Up Bus
/i2c-pullup-bus
22. Battery Life & Sleep
/battery-life-calculator
23. PCB Trace Width
/pcb-trace-width
24. Wheatstone Bridge
/wheatstone-bridge
25. Raspberry Pi GPIO
/raspberry-pi-pinout
26. WS2812B LED Strip
/ws2812b-led-strip
27. SG90 Servo PWM
/servo-pwm-control
28. HC-SR04 Ultrasonic
/ultrasonic-hcsr04
29. Opto Relay Module
/relay-optocoupler
30. 3.3V ⇄ 5V Shifter
/logic-level-shifter