HC-SR04 Ultrasonic Distance Sensor

5,426 views

An Overview of HC-SR04 Sensor

Ultrasonic sensors are very compact devices used to sense ultrasonic energy. The sensor essentially calculates the distance of the targeted object. We usually use it as a proximity sensor. It has more applications in automobiles. Precisely, used to make a system secure.

The HS-SR04 ultrasonic sensor, which is also known as SONAR detects the distance with high accuracy and always gives reliable readings. Even, Black material or sunlight can’t affect the system.

Working of Sensor

The HC-SR04 employs non-contact sonar that measures the distance of an object. The sensor comprises two ultrasonic transmitters, a receiver The transmitters transmit an ultrasonic sound of high frequency, which bounces off any nearby solid objects, then the receiver observes for any return echo. There is control circuitry that then deals with that echo to calculate the time difference between the signal being transmitted and received. To calculate the distance between the targeted object and the sensor, the formula: D=1/2 T×C is used. Where T is the time between the transmitter and receiver. While C is the speed of sound

Interfacing with Microcontroller

To interface, first, you need to power the Sensor by a regulated 5V using the Power and ground pins of the sensor. The echo and trigger pins of the sensor are the input/ output pins and therefore you need to connect those pins with the I/O pins of the microcontroller. At the start, the trigger pin has to be made high for 10uS and then needs to turn off. This step triggers an ultrasonic wave at a frequency of 40Hz from the transmitter, the receiver then waits for the wave to return. Once the wave is returned, the Echo pin goes high for a specific amount of time which will be equal to the time taken for the wave to return to the sensor.

Features and Specifications of HC-SR04

Features

  • Provides a 2cm – 400cm non-contact measurement function
  • The ranging accuracy can reach to 3mm.
  • The modules include ultrasonic transmitters, receiver and control circuit.

Specifications

  • Working Voltage: DC 5V
  • Current: 15mA
  • Working Frequency: 40Hz
  • Max Range: 4m
  • Min Range: 2cm
  • Measuring Angle: 15 degree
  • Trigger Input Signal: 10µS TTL pulse
  • Echo Output Signal Input TTL lever signal and the range in proportion
  • Dimension 45 * 20 * 15mm

HC-SR04 Pinout

Pin NumberPin NameDescription
1VccThe power pin of the sensor requires 5V
2TriggerAn input trigger pin needs to be kept high for 10us to initialize measurement.
3EchoAn output echo pin.
4GroundThe ground pin needs to connect to the ground of the system.

Applications of HC-SR04

Robotic navigation systems

The purpose of robotic navigation systems is to build a system that directs itself whenever an obstacle or interference comes in its path. Therefore, it uses the HC-SR04 ultrasonic sensor to detect any obstacle in front of
it and sends a command to the microcontroller of the robot.

Burgler Alarms

We can install the burger alarm near the door to detect anybody at the door. Whenever somebody comes between the range of HC-SR04 Ultrasonic sensor, the buzzer beeps. One can change the sensor detection range according to the door. This system basically performs motion detection.

Ultrasonic Anemometers

Ultrasonic Anemometers are used to detect wind speed and direction. The 2D anemometer only measures the horizontal component, while a 3D anemometer measures the vertical component of wind, as well.