NNexuStore
← All TutorialsSTEP BY STEP LEARNING

Measure Distance with HC-SR04

Overview

The HC-SR04 module measures approximate distance using ultrasonic pulses and the time between transmission and echo reception.

Parts

Arduino-compatible 5 V board, HC-SR04 module, breadboard and jumper wires.

Wiring example

  • VCC → regulated 5 V
  • GND → GND
  • TRIG → a configured digital output pin
  • ECHO → a configured digital input pin

Important: many HC-SR04 echo outputs are 5 V. Use a suitable logic-level conversion method when connecting to a 3.3 V controller such as ESP32.

Try it

Send a short trigger pulse, measure echo duration and estimate distance from the speed of sound. Test against a ruler and note how angle and surface material affect readings.