What is HC-SR04 Ultrasonic Sensor : Working and Its Applications

The HC-SR04 ultrasonic sensor includes a transmitter & a receiver. This sensor is used to find out the distance from the objective. Here the amount of time taken to transmit and receive the waves will decide the distance between the sensor and an object. This sensor uses sound waves by using non-contact technology. By using this sensor the distance which is required for the target can be measured without damage and provides accurate details. The range of this sensor available between 2cms to 400cms.

What is the HC-SR04 Ultrasonic Sensor?

The HC-SR04 is a type of ultrasonic sensor which uses sonar to find out the distance of the object from the sensor. It provides an outstanding range of non-contact detection with high accuracy & stable readings. It includes two modules like ultrasonic transmitter & receiver. This sensor is used in a variety of applications like measurement of direction and speed, burglar alarms, medical, sonar, humidifiers, wireless charging, non-destructive testing, and ultrasonography.


HC-SR04 Ultrasonic Sensor Pin Configuration

This sensor includes four pins and the pin configuration of this sensor is discussed below.

  • Pin1 (Vcc): This pin provides a +5V power supply to the sensor.
  • Pin2 (Trigger): This is an input pin, used to initialize measurement by transmitting ultrasonic waves by keeping this pin high for 10us.
  • Pin3 (Echo): This is an output pin, which goes high for a specific time period and it will be equivalent to the duration of the time for the wave to return back to the sensor.
  • Pin4 (Ground): This is a GND pin used to connect to the GND of the system.


The features of the HC-SR04 sensor include the following

  • The power supply used for this sensor is +5V DC
  • Dimension is 45mm x 20mm x 15mm
  • Quiescent current used for this sensor is <2mA
  • The input pulse width of trigger is10uS
  • Operating current is 15mA
  • Measuring angle is 30 degrees
  • The distance range is 2cm to 800 cm
  • Resolution is 0.3 cm
  • Effectual Angle is <15°
  • Operating frequency range is 40Hz
  • Accuracy is 3mm

HC-SR04 Ultrasonic Sensor Working

The HC-SR04 Ultrasonic sensor comes with four pins namely Vcc pin, Trigger pin, Echo pin, & Ground pin. This sensor is used to measure the accurate distance between the target and the sensor. This sensor mostly works on the sound waves.

When the power supply is given to this module, it generates the sound waves to travel throughout the air to hit the necessary object. These waves strike and come back from the object, then collects by the receiver module.


Here both the distance as well as time has taken is directly proportional because the time taken for more distance is high. If the trigger pin is kept high for 10 µs, then the ultrasonic waves will be generated which will travel at the sound speed. So it creates eight cycles of sonic burst that will be gathered within the Echo pin. This ultrasonic sensor is interfaced with Arduino to gauge the necessary distance between sensor & object. The distance can be calculated using the following formula.

S = (V x t)/2

Where the ‘S’ is the required distance

‘V’ is the sound’s speed

‘t’ is the time taken for sound waves to return back after striking the object.

The actual distance can be calculated by dividing its value with 2 as the time will be twice once the waves travel and get back from the sensor.

HC-SR04 Ultrasonic Sensor with Arduino Board

Here we are giving an example for the HC-SR04 ultrasonic sensor using the Arduino board. This sensor is interfaced with an Arduino board.


The required components of this project mainly include the Arduino UNO board, HC-SR04 ultrasonic sensor, breadboard, and jumper wires. The connections of this project are very simple like the following.

  • The VCC pin of the sensor is connected to 5V of the Arduino
  • The Trig pin of the sensor is connected to Pin 11 in the Arduino
  • The Echo pin of the sensor is connected to Pin 12 in the Arduino
  • The GND pin of the sensor is connected to GND pin in the Arduino


The measurement of accurate distance can be achieved by interfacing the HC-SR04 sensor with different types of Arduino boards.

At first, give the power supply to the sensor to turn on and connect the GND pin of this sensor to the GND pin of the Arduino board. And the sensor module can be powered up with the voltage supply of the Arduino board when the current which is drawn through the sensor is below 15mA. So the Arduino current ratings will not affect the sensor.

Once the primary arrangement is set up then connect both the pins of sensors like Trig & Echo to the Arduino board’s input/output pins. As we discussed earlier, the Trig pin in the sensor must be kept 10us in the beginning in order to start the measurement method. So, this sensor module will generate sound waves by the 40,000 Hz frequency around for every second from the source.

When the sound waves return back, the Echo pin will activate until these waves are obtained by the receiver. The time will be measured with the help of an Arduino board.


The applications of HC-SR04 sensor include the following,

  • This sensor is used to measure speed as well as the direction between two objects
  • It is used in wireless charging
  • Medical ultrasonography
  • This is used to detect objects & avoid obstacles using robots such as biped, pathfinding, obstacle avoidance, etc.
  • Depth measurement
  • Humidifiers
  • This sensor is used to plot the objects nearby the sensor by revolving it
  • Non-destructive testing
  • By using this sensor depth of pits, wells can be measured by transmitting the waves through water.
  • Embedded system
  • Burglar alarms

Thus, this is all about the HC-SR04 ultrasonic sensor. From the above information finally, we can conclude that this sensor uses sonar to measure the distance between sensor and object. The transmitter sends a high-frequency sound signal. Once the signal discovers an object then it reflects back to the echo pin of the transmitter. The time taken for the signal transmission as well as reception permits us to determine the distance to an object. Here is a question for you, what are the same distance determining sensors?