Introduction: Arduino Ultrasonic Mobile Sonar
Have you ever wondered how to explore the inside of pyramid? The deep dark area of ocean? A cave that has just been discovered? These places are considered unsafe for men to enter, therefore an unmanned machine is required to do such exploration, such as robots, drones, etc. usually equipped with cameras, Infrared cameras, etc. to view and map the unknown area live, but these requires certain light intensity, and the data acquired is relatively large. Therefore, sonar system is considered a general alternative.
Now, we can build one remote controlled sonar radar vehicle by using an ultrasonic sensor. This method is inexpensive, relatively easy to get the components and easy to build, and the more important, it helps us understand better the basic system of advanced aerial scanning and mapping instruments.
Step 1: Basic Theory
The HC-SR04 ultrasonic sensor used in this project is capable of scanning from 2cm up to 400cm. We attach the sensor on a servo motor in order to build a functioning sonar that turns. We set the servo to turn for 0.1 second and stop for another 0.1 second, simultaneously until it reaches 180 degrees, and repeat by returning to initial position, and using Arduino we will obtain the sensor's reading at the moment everytime the servo stops. Combining the data, we sketch a graph of distance readings for 400 cm radius in 180 degrees range.
MPU-6050 accelerometer sensor is used to measure the amount of accelerations about the x, y and z axis. From the change of measurements with a rate of change of 0.3 seconds we obtain displacements around these axis, which can be combined with sonar data to pinpoint the position of every scan. The data can be viewed from the serial monitor in Arduino IDE.
C. RC 2WD Car
The module uses 2 DC motors which is controlled by L298N motor driver. Basically the movement is controlled by the rotating speed (between high and low) of each motors and its direction. In the code, controls of movement (forward, backward, left, right) are converted into commands to control the speed and direction of each motor, then transmitted through the motor driver which controls the motors. HC-06 Bluetooth module is used to provide wireless connection between Arduino and any Android based devices. After the module is connected with transmitting and receiving pin, it is connected with the device. User can install any Bluetooth control app and set up 5 basic buttons and assign simple commands of (l,r,f,b and s) to the button once connection is established. (the default pairing code is 0000) Then the circuit of control is done.
D. Connection with PC and Data Result
The data obtained needs to be transmitted back to the PC in order to be read by Arduino and MATLAB to be processed. The suitable method would be setting up a wireless connection using a wifi module such as ESP8266. The module sets up a wireless network, and the PC is required to connect to it and read through the wireless connection port to read the data. In this case, we still use USB data cable to connect to PC for prototype.
Step 2: Parts and Components
Step 3: Assembling & Wiring
1. Attach the ultrasonic sensor on the mini breadboard, and attach the mini breadboard onto the servo's wing. The servo should be attached at the front of the car kit.
2. Assembling the car kit by following the instructions included.
3. The rest of the parts' position can be freely arranged depending on the wiring layout.
Except for L298N motor driver, the rest of the parts only require 5V power input that can be obtained from Arduino's 5V output port, while the GND pins to Arduino's GND port, therefore the power and GND can be aligned at the breadboard. For the Arduino, the power is obtained from the USB cable, either attached to PC or powerbank.
B. HC-SR04 Ultrasonic Sensor
Trigger Pin - 7
Echo Pin - 4
C. SG-90 Servo
Control Pin - 13
D. HC-06 Bluetooth Module
Rx Pin - 12
Tx Pin - 11
Front - 'f'
Back - 'b'
Left - 'l'
Right - 'r'
Stop any movement - 's'
E. MPU-6050 Accelerometer
SCL Pin - Analog 5
SDA Pin - Analog 4
INT Pin - 2
F. L298N Motor Driver
Vcc - 9V battery & Arduino 5V output
GND - Any GND & 9V battery
+5 - Arduino VIN input
INA - 5
INB - 6
INC - 9
IND - 10
OUTA - Right DC Motor -
OUTB - Right DC Motor +
OUTC - Left DC Motor -
OUTD - Left DC Motor +
ENA - Driver 5V (Circuit Breaker)
ENB - Driver 5V (Circuit Breaker)
Step 4: Arduino Code
Credits to the creators of original codes included in the file, and Satyavrat
Step 5: MATLAB Code
Please change the COM port according to the port you are using.
The code will obtain the data transmitted from Arduino through the port. Once it is run, it collects the data frequently following the amount of sweeps the sonar perform. The running MATLAB code needs to be stopped in order to obtain data in the form of graphic plots of an arc. The distance from center point to the graph is the distance measured by the sonar.
Step 6: Result
Step 7: Conclusion
For precision usage, this project is far from perfect therefore unsuitable for professional measuring tasks. But this is a good DIY project for explorers to get into the knowledge of sonar, and Arduino projects.
We have a be nice policy.
Please be positive and constructive.