The AI ArduBuoy Uses the Power of Machine Learning and Sonar to Detect Ships

By combining an Arduino-based board and a hydrophone acoustic sensor, Luke Berndt was able to detect ships with almost 100% accuracy.

Capturing sounds from a hydrophone

Hydrophones can be thought of as underwater microphones. Rather than picking up sounds by having a membrane move from small vibrations in the air, their membranes move when vibrations in the water hit their diaphragms. Luke Berndt on Twitter wished to use a hydrophone to detect ships, which is nothing new, but he wanted to take it one step further by incorporating machine learning to make his device more precise.

Berndt's project, the AI SonoBuoy, has a single hydrophone sensor at its heart. The one he opted for is the H2A hydrophone module from Aquarian Hydrophones, and it was built with the ability to simply plug into an audio interface via a 3.5mm jack for easy recording.

Designing an add-on board

In order to grab the incoming waveforms from the hydrophone and convert them into digital data, Berndt needed a way to plug in the device and run the analog signal through an ADC. Because he was unable to find an off-the-shelf board, he designed a custom one based on Adafruit's Electret Mic breakout. By doing it this way, the hydrophone could be connected directly over a 3.5mm jack but also have its gain adjusted with a potentiometer.

Learning to recognize a boat

Before any model training could be done, there first had to be a large dataset containing both audio samples from the hydrophone and labels corresponding to either "boat" or "no boat." One program that Berndt wrote runs on an Adafruit PyBadge, and all it does is read a sample from the sensor at a regular interval with the help of an interrupt.

After going through the arduous process of collecting large amounts of data and labeling it, Berndt used the AutoML feature in Edge Impulse that ran these samples through a spectrogram generator and then a 2D Convolution layer within Keras. Once fully trained, the model was able to achieve an impressive 99.7% accuracy.

How well does it work?

Berndt deployed his model to the PyBadge in the form of an Arduino library, which made the programming a lot easier. His code is largely comprised of a single main loop that reads in samples from the microphone, gets the inferencing result from the neural network model, and then displays it on the screen. As an added bonus, the actual waveform is also shown on the LCD.

You can find all of the code and design files here on GitHub.

Evan Rust
IoT, web, and embedded systems enthusiast. Contact me for product reviews or custom project requests.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles