HC-SR04 Ultrasonic module interface with Arduino

HC-SR04 as known as Ultrasonic sensor is non-contact range detection module used for distance measurement, radar & object displacement etc. It offers high accuracy, steady readings & easy interface pin-out to interface with various microcontroller boards as ultrasonic transceiver. Interfacing HC-SR04 with your Arduino and enhance object detection feature in your DIY project.HC-SR04

Features & Specifications

  • Power Supply :+5V DC
  • Quiescent Current : <2mA
  • Working Current: 15mA
  • Effectual Angle: <15°
  • Ranging Distance : 2 cm – 400 cm / 1″ ­ 13ft
  • Resolution : 0.3 cm
  • Measuring Angle: 30 degree
  • Trigger Input Pulse width: 10uS
  • Dimension: 45mm x 20mm x 15mm
  • Weight: approx. 10 g


HC-SR04 pinout

  • Vcc: +5V DC to power ON the module.
  • Trig: Trigger pin is an Input pin. This pin has to be kept high for 10µs to initialize measurement by sending ultrasonic wave.
  • Echo: Echo pin is an Output pin. This pin goes high for a period of time which will be equal to the time taken for the ultrasonic wave to return back to the sensor.
  • GND: Ground of the system.

As shown above the HC-SR04 Ultrasonic sensor there are 4 pins: Vcc, Trigger, Echo and Ground respectively. This sensor is most popular where measuring distance or sensing objects are required. The module has two components in the front which works as Ultrasonic transmitter and Receiver. The sensor works with the simple formula “Distance = Speed × Time”. The Ultrasonic transmitter transmits an ultrasonic wave, this wave travels in air and when it gets objected by any material it gets reflected back toward the sensor this reflected wave is observed by the Ultrasonic receiver module.

Connection with Arduino

Arduino  HC-SR04
Vcc  Vcc
D09 Trig
D10  Echo
Gnd  Gnd


You can download this code from here.

Open the code in Arduino IDE, upload it & get distance values on serial monitor screen. I hope this tutorial will be helpful for HC-SR04 interface in your Arduino projects. Further in this you can interface LCD to display distance & interface HC-05 bluetooth module to send distance values via bluetooth. Your feedback will be appreciated.

Subscribe BYB on FacebookTwitterInstagram & Telegram for latest updates.

Leave a Reply

Your email address will not be published. Required fields are marked *