Ultrasonic Module
The HC-SR04 ultrasonic module measures distance by sending a 40 kHz sound pulse and timing the echo.
Part images
What it is
The HC-SR04 ultrasonic module measures distance by sending a 40 kHz sound pulse and timing the echo.
How students use it
Students use it for distance meters, parking sensors, obstacle warnings, robot-style sensing, and projects that react before touching an object.
Pins and power
TRIG trigger pulse input, ECHO echo pulse output, GND, and VCC 5V supply.
SunFounder lists VCC as 5V, working current 16mA, and Echo as a TTL pulse output. Protect Pico GPIO if Echo is 5V.
Trigger with at least a 10us high pulse. Echo high duration represents round-trip sound time; distance is time times sound speed divided by two.
Voltage and safety
The 5V Echo pulse is not Pico-safe without level shifting or a divider. Connect GND first when wiring as SunFounder cautions.
Power off before rewiring. Use large flat targets for reliable testing and do not rely on it as a safety-critical detector.
Module internals
Main component: HC-SR04 ultrasonic distance sensor module identified by SunFounder.
Ultrasonic transmitter, ultrasonic receiver, control circuit, four-pin header, and support components.
Datasheet notes
SunFounder lists range 2cm to 400cm with up to 3mm accuracy, features table max range 500cm, min range 2cm, 40Hz, 10us trigger, and XH2.54-4P connector.
Common libraries
Use machine.Pin and machine.time_pulse_us to generate the trigger and measure echo pulse width.
Common mistakes
Connecting Echo directly to Pico without level shifting, measuring tiny/soft/angled targets, forgetting shared ground, and using readings before the echo timeout is handled.