stemduniya ultrasonic sensor

ULTRASONIC SENSOR: HC-SR04 MODULE

With an accuracy of 3mm, Ultrasonic sensor HC-SR04 is used to detect the distance of an object by emitting ultrasonic sound waves towards it, and detecting the reflecting waves (which gets reflected by hitting the target object). It has two parts: Transmitter and Receiver. The Transmitter part transmits the sound waves towards the target object. And the Receiver detects the signals it gets back after hitting the object. From those received signals it calculates the distance. It basically calculates the time taken by the sound signals to travel from transmitter to object to receiver

The HC-SR04 ultrasonic sensor has 4 Pins:

PIN 1 Vcc Its function is to supply voltage to the sensor, with +5V
PIN 2 Trigger Its function is to supply voltage to the sensor, with +5V
PIN 3 Echo It is an OUTPUT pin, which goes for a particular time span.
PIN 4 Ground This pin is connected to Ground of the system

This distance can be calculated by using the very basic formula:


Distance= Speed X Time

Distance: between the sensor and the object
Time: time taken by the US sound waves to reach the object and then reflected back and captured by the receiver
Speed: speed of sound wave (343 m/s)

The figure above shows the labelled diagram of HC-SR04 sensor and the working of it.
HC-SR04 sensor is suitable for both microcontrollers and microprocessors. Its button like structure contains transmitter and receiver along with 4 Pins which are connected to the microcontroller or the microprocessor. This ultrasonic sensor works with an operating current less than 15mA and voltage supply of +5V. The Trigger is the input pin and the Echo is the Output pins which are connected to the I/O pins of the microcontroller. The trigger pin is set HIGH to begin the measurement for 10Ξs and after that it is turned off. The function of trigger pin is to transmit an Ultrasonic sound wave of 40Hz frequency towards the target object and this transmission happens when it is turned HIGH. When the sound wave hits the object, the Echo pin goes HIGH and remains the same until the wave reflected by the object gets received at the receiver of the sensor. And this time during which the Echo pins remains HIGH is calculated by the microprocessor or the microcontroller. And then by applying the formula for distance, the value gets calculated.

The formula used to calculate distance theoretically is:


Distance= Speed of time X time/2

As the distance calculated without dividing by 2 was the total distance travelled from transmitter to object to receiver, therefore the distance between the sensor and object will be half of that.
The figure above shows the timing diagram of the Trigger signal. When the trigger pin is set high for 10ΞS, during which eight ultrasonic waves are generated which initiates a time counter. The timer stops when the reflected or echoed signal is received. The following formulae are used to calculate the distance from time signals:


Distance (cm) =𝒆𝒄𝒉𝒐 𝒑𝒖𝒍𝒔𝒆 𝒘𝒊𝒅𝒕𝒉(𝒖𝒔)/𝟓𝟖

Distance (inch) = 𝒆𝒄𝒉𝒐 𝒑𝒖𝒍𝒔𝒆 𝒘𝒊𝒅𝒕𝒉 (𝒖𝒔)/𝟏𝟒𝟖

The HC-SR04 sensor can be used to measure the distance from 2cm to 450cm which is the theoretical measuring distance. And the Practical Distance is from 2cm to 80cm. In the nutshell, features of HC-SR04 ultrasonic sensor are as follows:


Ultrasonic sensors can be used in anti-collision safety systems, automobile self-parking system, and robotic obstacle detection system and can also be used as level sensors. Apart from that, they are also being used in medical field for generating images of internal organs, identifying tumors, and to check whether the baby is healthy in womb. UAV navigation (unmanned aerial vehicles) uses ultrasonic sensors to detect the obstacle or object in their path. Applications of US sensors also include web-guiding systems, tide gauge and ultrasonic anemometers.