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