Distance measurement using Ultrasonic sensor interfacing and Arduino, In this article you will learn about each and everything about very famous ultrasonic sensor HC-SR04. You will also learn how to interface ultrasonic sensor with Arduino Uno R3? What is ultrasonic sensor? Types of ultrasonic sensors available in market, applications of ultrasonic sensor. Programming and hardware part of ultrasonic sensor interfacing with Arduino Uno R3 and at the end of this article you will learn its famous use in distance measurement. Distance measurement using Ultrasonic sensor and Arduino Uno R3.
If you don’t know anything about Arduino, first go through following articles so that you can learn programming part of this article properly.
- 0.1 Getting started with Arduino Uno R3
- 0.2 Led blinking using Arduino Uno R3
- 0.3 LCD interfacing with Arduino Uno R3
- 0.4 How to interface push button with Arduino Uno R3
- 0.5 Analog voltage reading with Arduino Uno R3
- 1 What is Ultrasonic sensor?
- 2 Applications of Ultrasonic sensor
- 3 Distance measurement using Ultrasonic module and Arduino Uno
- 4 HC-SR04 ultrasonic module interfacing with Arduino Uno R3
What is Ultrasonic sensor?
Ultrasonic sensor is distance measurement sensor which use ultrasonic sound waves to measure distance. Ultrasonic sensor use high frequency sound waves of 40 KHz . Ultrasonic sensor consists of two basic modules transmitter and receiver. Transmitter acts as speaker and receiver acts as a microphone. Speaker emits ultrasonic waves and Microphone detect ultrasonic waves which is produced by speaker. Basic functionality of ultrasonic sensor is shown in diagram below :
As shown in above figure one part is acting as speaker which emit ultrasonic waves which after collision with any object return back. These returning waves are detect by Microphone. The time taken by microphone to receive ultrasonic waves from transmitter after collision with any object is used to measure distance. I will discuss it later how this time is used to measure distance from any object. Ultrasonic sensor works on the same principle as radio based radar system.
Applications of Ultrasonic sensor
There are many application of ultrasonic sensor from domestic use industrial use. But some of them are given below :
- Obstacle avoidance robot
- object detection
- distance measurement
- liquid level monitoring system
- Height measurement
- vehicle collision protection
In this article I will discuss only one application of ultrasonic sensor module that is distance measurement. But basics remains same, you can use same procedure to use ultrasonic sensor in your project.
Distance measurement using Ultrasonic module and Arduino Uno
As I have already discussed above, transmitter part of ultrasonic module emits ultrasonic high frequency waves in the form of of pulses. After collision of these waves with any object, these wave detect by microphone. Time taken by these waves from transmitter to receiver is used to measure distance from any object. There are many ultrasonic sensor modules are available in market but I will be using HC-SR04. This ultrasonic module is initiated with pulse of 10us.
The distance from any object is calculated using following formula :
distance = speed x time ;
We know that the speed of sound in air is 20C which is equal to 344 meter per second. The time given in above formula should also be divided by two. Because ultrasonic waves travel from transmitter and then go back to receiver by travelling same distance. So the formula to calculate distance becomes :
Distance = 344 x time / 2 meter ;
HC-SR04 ultrasonic module interfacing with Arduino Uno R3
I am using HC-SR04 ultrasonic sensor in this article. HC-SR04 Ultrasonic module have four pins. Description of each pin is given below:
- power supply pin Vcc 5 volt operating voltage for HC-SR04 sensor to work properly.
- Ground pin for zero potential.
- Trigger signal pin which is used to trigger HC-SR04 module with pulse of 10 micro second.
- Echo signal pin which is actually a receiver pin and used to listen to Ultrasonic sound wave which return after collision with any object.
Circuit diagram of ultrasonic HC-SR04 module interfacing with Arduino Uno R3 is given below along with connections :
To download code for above given circuit diagram click on following link :
if you have any issue after reading this article, let me know with your comment. Kindly don’t forget to share it with your friends thanks 🙂