IoT project of Sonar system using Ultrasonic Sensor HC-SR04 and Arduino device
Let’s build an IoT project of sonar system using Ultrasonic HC-SR04 device and Arduino (Arduino UNO). The sonar system detects the objects that come within its range (angle and distance) and display its appearance on Laptop (Monitor) screen. Sonar uses the echo principle of sound waves through an object.
Hardware requirements
- Arduino UNO board
- USB cable connector for Arduino UNO
- Ultra Sonic HC-SR04
- Jumper wires male to female
- Micro Server SG90
Software requirements
- Arduino software
- Processing software
The working principle of the Sonar system
The Ultra Sonic HC-SR04 emits ultrasound at 40,000Hz that travels in the air. If there is an object or obstacle comes in its path, then the sound wave collides with the object and bounces back to the Ultra Sonic module. The object’s angle and distance have displayed over the screen (Monitor).
In this project, we use the processing app to display the sonar range.
Before writing a program for Sonar system, first go through Ultrasonic Sensor HC-SR04 and Arduino to distance calculationwhere we provide the working principle of Ultrasonic device.
Write an Arduino program to measure distance using Ultra Sonic HC-SR04 and rotate servo motor.
Compile your code.
Now, connect the Arduino device with your personal computer using an Arduino USB connector and upload the program.
Digital circuit diagram
Ultrasonic Sensor HC-SR04 Arduino UNO
VCC ——————————–> 5v
Trig ——————————–> Pin 8
Echo ——————————–> Pin 9
GND ——————————–> GND
Micro Servo Motor SG90 Arduino UNO
Orange wire ———————-> Pin 10
Red wire ———————-> 3.3v
Brown wire ———————-> GND
Now, place the bigger part of a fan over servo motor’s rotating wheel. Place your Ultrasonic device over the servo motor to make it rotating (you may use double sided sticky tape).
Test the following code in the Processing IDE and run it. The Processing IDE displays the angle distance of an object when it comes in the range of Ultrasonic device.
Now, run your processing application and place an object (pen) in front of Ultrasonic device. When the servo motor rotates and objects come in the range of Ultrasonic device then the appearance of an object appears on display screen. The presence of an object is marked with the red mark and if there is no any object in the range of Ultrasonic device processing application display green marks.