LabWired The easy way to build hardware
board I/O module

HC-SR04

The HC-SR04 is a board I/O module in the LabWired part catalog. Its catalog type is ultrasonic. It connects to the MCU over GPIO. The catalog gives a supply range of 4.5–5.5 V. It has 4 pins. A device model in the simulation engine, reached through a dedicated dispatch path rather than the peripheral registry.

From the catalog: Dispatched as "hc-sr04" from bus/from_config.rs. SimInput channel: distance.

HC-SR04 in LabWired
Rendered by the matching LabWired editor component.

Key facts

CategoryBoard I/O modules
Catalog typeultrasonic
InterfaceGPIO
Supply range4.5–5.5 V
Pins4
DatasheetHC-SR04 ultrasonic sensor datasheet

What LabWired simulates

What is simulated

Simulated device model

How it was validated

Built from the datasheet

HC-SR04 pinout

PinElectrical typeFunction
VCC Power input Supply
GND Power input Supply
TRIG Input GPIO
ECHO Output GPIO

How to simulate the HC-SR04 in LabWired

  1. Open the Playground at app.labwired.com and place an MCU board.
  2. Add the HC-SR04 (catalog type ultrasonic).
  3. Connect VCC and GND to the supply and ground of the board. Use a supply inside the catalog range of 4.5–5.5 V.
  4. Connect TRIG and ECHO to free GPIO pins.
  5. Run the firmware. It drives and reads the pins of the part, and the device model responds on those pins.

Related Board I/O modules

All Board I/O modules · All parts

Further reading

Modelled from HC-SR04 ultrasonic sensor datasheet.