Spark Logic

HC-SR04 ultrasonic ranging module connection guide

HC-SR04 ultrasonic ranging module (Four-pin module header) connection guide. Measure a distance with a 5 V host.

Four-pin module header

4 contacts Current package

ELECFREAKS·

Measure a distance with a 5 V host

Required

Use a host with 5 V-compatible inputs and outputs. Share ground and power the module from a regulated 5 V supply.

  • +5 V
    • Regulated 5 V rail
  • Ground
    • Host ground
  • Trigger output
    • →
    • Host GPIO output
  • Echo capture
    • →
    • Host timer capture input

Bench checks

  • Set Trig low at idle. Send a pulse at least 10 µs long. Configure Echo as an input and impose a timer timeout so a missing echo cannot stall the host.
  • Point the module perpendicularly at a flat target 30 cm away. At about 343 m/s sound speed, the echo pulse should be about 1.75 ms.
  • Wait 60 ms between starts to keep later echoes from overlapping the next measurement.

ELECFREAKS HC-SR04 User Guide, pp. 3–4, §§ 2.3–2.5 and 3.1.

Four-pin module header wiring map

External wiring example · Measure a distance with a 5 V host

Highlighted contacts are used in this circuit. Select a contact to highlight its wiring nets.

Four-pin module header
Face the two transducers with the connector below them. VCC, Trig, Echo, and GND run left to right.
Selected pin details

1 · VCC

Supply input · Power

Connect to a regulated 5 V supply.

ELECFREAKS HC-SR04 User Guide, pp. 3–4, §§ 2.3–2.5 and 3.1.

Electrical limits · Pin in the reference

Models and documents

This map follows the 5 V ELECFREAKS HC-SR04. Check the markings and voltage limits on lookalike modules.

HC-SR04
5 V version documented by ELECFREAKS.