Processing Sound of Hummingbirds
I have a fun little project that records hummingbird visits to my feeders. Each time a bird visits, I record temperature, barometric pressure, humidity, and the weight of the nectar left in the feeder. I even try to weigh the bird if they sit down. Then I log that data into my website database: Project Database. I am working to get nice looking graphs of this data to visualize things better.
I need to add a 2nd method of detecting hummingbird visits to my feeders. Currently I use a PIR (Passive InfraRed) sensor, that is used in most motion detectors.
Here is one configuration with the PIR looking down to the feeder:
The problem with this configuration is that it will detect many false positives, like the feeder swinging in the breeze, or a cat walking by on the ground, or me cooking burgers on the deck.
Here is another configuration I have tried:
Here the PIR faces up. To eliminate the feeder and breeze issue the feeder is attached to the bracket. The problem here is that the bracket hangs down too far and interferes with my deck access. In addition, when placed in another location, the swaying trees above constantly set it off.
So it is clear that I need a secondary detection method. The unit can sleep until the PIR is activated by motion, and then my detector will listen to the ambient sound. Hummingbirds have a very distinctive sound. Their wings flap right around 100Hz. I would like to program my micro-controller to process the sound from the microphone, and if it detects the dominant frequency to be between 50Hz and 200Hz then it will record a bird visit, if not it will go back to sleep.
I have stripped the sound out of this YouTube video:https://youtu.be/0vgRYTPV9qU as an mp3 file.
Here is the file:
Then I imported the file into Audacity. I highlighted the areas where the birds were buzzing:
Then I choose Analyze Spectrum from the Analyze menu. The plot looks pretty good, with the largest peak at 96Hz.
I am having a challenge getting my ESP32 processor to recognize the peak frequency. I have tried playing the sound and placing the sound detector close to my speaker. I have tried a frequency generator to play a single frequency (440Hz, for example). It doesn’t identify the sound reliably. I am using this simple microphone:
I have read lots of stuff, and the example project I am trying is outlined here:
I didn’t get good results with it. So I may try this library: