Maker.io main logo

DIY Arduino Ultrasonic Sonar - Radar on TFT display

2024-05-13 | By Mirko Pavleski

License: General Public License Radar Ultrasonic Arduino

Ultrasonic sonar devices use sound waves with frequencies higher than the upper audible limit of human hearing (typically above 20 kHz) to measure distances to objects. They work on the principle of sending out a sound wave, and then measuring the time it takes for the sound wave to bounce back after hitting an object. By calculating the time difference between sending and receiving the sound wave, the distance to the object can be determined using the speed of sound in air. In some of my previous videos, you can see several different builds of such a device with special functionalities. All of them display the result on a PC monitor using an additional program written in the Processing application. This time I will describe to you a simple way how to make an independent sonar, where the results are displayed on a TFT color display in the form of a radar image, which is why it is often mistakenly called radar instead of sonar.

 

I got the idea quite by accident from a picture on the internet, and then after a little research I found that project on Github. The original project was made on a 1.8 inch display which is really a very small surface for this purpose. So, I reworked the code for a larger 3.2 inch TFT display, where the image is much clearer.

hjbkiji

The device is really simple to make and consists of only a few components

- Arduino Nano microcontroller board

- TFT display with a resolution of 240 x 320 pixels and an ILI9341 driver chip

- Ultrasonic sensor type HC-SR04

- small 9G Servo

- and several resistors that serve to shift the display signal from 5V to 3.3V level.

The servo and ultrasonic sensor are housed in a separate box, which I used from a previous project, and connected to the main box with flat cables.

hjuohio

Now let's see how the device works in real conditions: At the beginning, I separated the ultrasonic sensor from the servo in order to calibrate the graphic presentation with the real distance of the object. As you can see, the real distance fully corresponds to the distance shown on the display.

fcghcf

Now we mount the sensor on the servo and place the obstacles to be detected. At power on, the servo is tested first, then the radar-like screen is drawn on the display and scanning begins.

bhjkj

Obstacles are marked with red dots. In the lower-left corner, the scanning area is displayed, and on the right, the distance between the sensor and the obstacle is displayed in centimeters. The three green arcs with marked distances provide easier visibility and an idea of the real distance. If the nearest obstacle is greater than 1-meter, yellow dots are drawn on the last arc, indicating an out-of-range condition. Scanning is performed first from 180 to 0 degrees, and then vice versa, from 0 to 180 degrees.

jkl

For the sake of stability during operation, the device is preferably powered by an external power source, but it also works via USB on the Arduino. All display colors can be easily changed in the code according to the user's preference. And finally, a short conclusion. Most such devices show the scan result on a PC monitor which requires an additional application and code. This is a very simple, easy to make, visually effective, and self-contained device intended for both beginners and more advanced DIYers. I've used cases from previous projects, but it's desirable to have it all in one case with a slanted front display to visually simulate a real radar system.

jkjnh

 

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.