This device is a small, portable ultrasonic range meter using an ATMega328 microcontroller, an ultrasonic module and a 4x20 LCD for ranging distances in meters and inches.
Step 1: Theory
In Physics, sound is the result of the mechanical vibration of a material and characterized as the mechanical waves that carry mechanical energy. For the transmission of these waves, it is necessary the existence of some material between the transmitter and the receiver. This material can be any type, such as solid, fluid or gas. When a kind of disturbance happens because of an incentive, the moving molecules of the material exercise forces on their neighbor ones, making them leave their equilibrium position. By this way, this disturbance travels through the material and this phenomenon is called propagation of sound waves.
In ambient air under normal conditions, the speed of sound is about 331.5 meters per second or 1087 feet per second. This speed is proportional to temperature and pressure of air and is completely independent from the frequency and magnitude of the sound. As the water waves, the sound waves have the same physical characteristics such as wave length, frequency and the capability of reflection.
This device, sends an ultrasonic pulse (i.e. a small burst of sound in a frequency that is above the upper limit the human ear can operate) and measures the time since the beginning of sound burst and the time until this burst comes back because of a reflection on a solid surface. Knowing the standard speed of sound in the air, we can calculate the distance between the front of the device and the obstacle we are pointing to.
Step 2: Materials Required
The sensing device of the Portable Ultrasonic Range Meter is a small ultrasonic module of HC-SR04 type with trigger and echo. For the user interface a 4 rows / 20 characters LCD is used and the commands initiated through a small piece of membrane 4ple tactile switch. All of the above are controlled by an ATMega328 microcontroller, supplied with 5VDC from a 9V battery in the enclosure. A, the enclosure is a small RETEX ABS one I had...
All the construction was made on a piece of one side, pre-holed general purpose pcb and the wiring between the parts wit 0.25mm Kynar wire.
Step 3: Assembly
At first, I cut out the LCD on the front of the enclosure and then the 2 holes of the ultrasonic transducers on the front. The exact location of the holes depends on how someone builds the construction. I had also to open a slice opening at the lower front surface for the membrane ribbon cable. The rest of the parts were assembled an the pcb with the aim of angled headers, so the ultrasonic module could have a 90 deg angle to the front of the device.
The complete schematic was made with Altium Designer.
Step 4: Code and Schematics
I used the famous Arduino IDE platform for writing and compiling the code with libraries you can find as zipped files. You have to unzip them in your C:\...\arduino xxx\libraries path as files and after this, you have to re-compile the sketch before burning it in the microcontroller.
Notice: The ATMega328 does not have USB to serial communication, neither boot loader installed. You have to burn the entire flash through ISP connector with an appropriate programmer. Or you can program the controller on an Arduino UNO.
Step 5: How to Operate
My mother language is Greek, so the code is proudly written with Greek messages. In a future version of code, I will implement an English language option.
The device goes to sleep after about 40 seconds of operation after the measurement for conserving the battery's life as much as possible. In every case, there is also an external power switch so the battery is completely disconnected from the circuit.
After the powering on, you simply have to point to an obstacle and the distance will appear on the screen.
My YouTube Channel: