# Arduino Ultrasonic Object Localisation

Arduinos used for performing ultrasonic localisation

I develop a small toy setup with a pair of Arduinos and some ultrasound sensors to do object localization. The goal is to have at least 4 echo distances in each measurement to assert a unique solution of the localization equations. In addition to the position I also want to compute some validation criteria.

## The Hardware

I’m using two Arduino Unos and 6 HC-SR04 ultrasonic sensors. Each Arduino is in control of 3 sensors and the sensors are placed in two rows of 3 sensors each (see below). Both Arduinos are connected to a central computer which does the actual computations. The task of the Arduinos is to trigger an ultrasonic measurement and provide the echo data (i.e. sensor position and echo distance) to the central computer. The central computer gathers the measurements and solves the occurring equations to determine the position of the detected objects.

I’m using two Arduinos for the following reasons:

1. Each sensor requires 4 cables. Attaching all 6 sensors on a single board would exhaust the existing pins.
2. More data requires more processing power. From a mathematical point of view, 3 echo distances would be enough to yield an object position. However, you have a lot more options to do data validation and statistics if you gather a few more echoes. Also, I was thinking about attaching a small OLED screen to the Arduinos to display some information. Having a few resources left will be useful.
3. This is a toy project and I thought it would be fun to connect the Arduinos to a Raspberry Pi and do the computation on an HPC Cluster. It’ll be interesting to come up with algorithms that can be parallelized.

As already mentioned, the sensors are aligned on two rows of 3 sensors each. The sensors for each row are connected to a breadboard. If I want the equations later on to have a unique solution, then I must ensure that I have echoes from sensors which are not collinear (not coplanar would be even better). To this end I’ve built a simple housing to hold the breadboards with the sensors. The housing is made from Legos and features two drawers where you can insert the breadboards.

The rear features convenient holes to route all cables through.

All in all, the full setup looks as follows. The Arduinos have been glued to the sides and the cables are routed from the back to the sides.

The electric circuit itself is rather straightforward. We attach 3 ultrasonic sensors to a breadboard and connect everything to the Arduino. The setup is repeated for the upper and lower drawer.

## Source Code

The code is hosted on Gitlab and MIT licensed. The project setup also uses the CI/CD services provided by Gitlab. Unit tests are run automatically. The code is compiled and checked with gcc and clang and a doxygen documentation is generated as well.

## References

The circuit diagram uses vector graphics taken from freesvg.org

###### Mathematician and Software Engineer

Researcher, Engineer, Tinkerer, Scholar, Philosopher, and Hyrox afficionado