How to interface the HC-SR04 ultrasonic ranging module to Arduino

 

How to interface the HC-SR04 ultrasonic ranging module to Arduino

If you are sourcing an ultrasonic ranging module, the HC-SR04 is a good choose . Its stable performance and high ranging accuracy  make it a popular module in electronic market.

Specifications:

  • power supply        :  5V DC
  • quiescent current :  <=2mA
  • effectual angle     :  <= 15°
  • ranging distance  :  3 cm – 400 cm
  • resolution             :  0.3 cm



There are 4 pins out of the module : VCC , Trig, Echo, GND . So it’s a very easy interface for controller to use it ranging. 

 

  • Pull the Trig pin to high level  for more than 10us impulse, so the module starts ranging;
  • If you find an object in front , Echo pin will be high level, and based on the different distance, it will take the different duration of high level. 
  • Compute the distance: Distance = ((Duration of high level)*(Sonic :340m/s))/2

Here you are a simple sketch, to work with it you must connect the hc-sr04 to your arduino board using the following scheme:

 

We have some of these sensors, if you are interested take a look here.

 

Gg1

Releated Post

7 thoughts on “How to interface the HC-SR04 ultrasonic ranging module to Arduino

  1. Hey guys 
    I'am Brazilian so sorry for english. I had been studing the header file of the library and i discovered a way to make the library work again well on the IDE 1.0.1 of arduino. inside de header file and the .cpp archive you just need to replace de library included wprogram.h for the library Arduino.h and them the your life will become prety simple.

  2. very simple and good article, I followed the steps and am very pleased.. In addition, I connected a LCD display

Leave a Reply

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