Magpie Finder
A hand-held device that tells you when a magpie is nearby.
Background
I recently developed birding as a hobby. As a beginner, I always have a hard time identifying the species. Luckily, there is an app/website called ’BirdNET’ which utilizes machine learning to recognize bird by sound. I wonder if it is possible to make the ML recognition on edge with the help of TensorFlow lite. So it can count birds on its own with very little power consumption.
Sampling & Training
I got most of my dataset from Xeno-canto because my own recording from a nearby park just had too much noise (mostly from cicadas). Then I cut them to 1 second clips and feed to the Jupyter Notebook arranged from the Micro Speech Training.
My dataset only contained 40 Eurasian-tree Sparrow recordings and 40 Oriental Magpie recordings since they are the most common birds in Beijing.
After about 1 hour training, I got the result of 95% accuracy. But the Arduino test didn’t go well. It kept detecting sparrows even when I was playing nothing. (I was initially trying to make it recognizes both sparrow and magpie.) Luckily, It recognized the magpie sound pretty ok so I turn my plan to only one species.
Fabrication
This was my favorite part. Because this was a bird themed project, I decided to show a flappy bird which wing is gonna controlled by servos. Everytime it detect the sound of a magpie, it flapped its wing.
I first tested it on a breadboard and it worked pretty good. There were still two servos because of my original two birds plan.
I soldered the circuit on a protoboard in order to reduce size and made the enclosure with black cardboard. Most components were placed with nylon stickers so I can swap the expensive ones for another project. In the left of the Arduino was a GPS module which is for future upgrade.
Then I designed the graphics and printed the parts with a photo printer. The appearance was mostly from the Oriental Magpie which is seen as an omen of good fortune in China.
Here is a test after full assembly. It showed good accuracy on recordings but acted really badly in real life. It could be from the lack of datasets or the unsuited model design. I’m pretty satisfied with the result for now although there is still a long way to go.
Expansion & Improvement
To make it more practical, I was thinking to add a GPS or RTC to expand the data collection in the time or location domain. So It can monitor species activity in one location for a day or the distribution of a species in a large area or both.
The great power-efficiency and low price makes the tensorflow lite for microcontroller a perfect match for this scenario. It would be possible to distribute a bunch of module with battery that can last for several day and still maintain affordable cost.
Materials & Code
- Arduino Nano 33 BLE Sense
- 180 degree Servo
- Power Bank
- Black Cardboard & Wires
Source code: https://github.com/jasongao97/magpie-finder