Sensor Digital

Ultrasonic Module

The HC-SR04 ultrasonic module measures distance by sending a 40 kHz sound pulse and timing the echo.

Part images

HC-SR04 ultrasonic module. Two transducers send and receive the ultrasonic pulse. Image source: SunFounder Pico 2 W Starter Kit documentation, Components section, © 2026 SunFounder.
Ultrasonic timing principle. Echo pulse width represents sound travel time out and back. Image source: SunFounder Pico 2 W Starter Kit documentation, Components section, © 2026 SunFounder.

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.