Friday, 31 July 2015

Bat Detector Overhaul: Automation

In England, the number of bats is declining, and has been for the last 100 years.


Organisations like the Bat Conservation Trust are always looking for volunteers to gather and post information on bat numbers and species in your local area.


While I'm neither a bat expert nor a bat volunteer, I thought it might be interesting to automatically gather data from a fixed location (...as this would save me poncing around the fields in the dark!).

By using a fixed, automatic system, it should be possible to gather data all night, every night, without losing sleep or suffering hyperthermia.

Results could then be compared on a month-by-month and possibly year-by-year basis.

The big idea


I'm thinking about a system located in (and on) my garage, with a roof or mast-head unit feeding back to a Pi based recorder inside the garage.

Automatic Bat Survey System

The mast-head unit consists of a microphone and a bandpass filter. This just needs to cover the range of frequencies that I'm interested in (probably 20 - 80kHz). The output is fed down into the garage where it is amplified (to the very edge of instability!) and divided down to frequencies within the audio range.

The divide by 32 output from the divider is fed to the Raspberry Pi gpio and used as a trigger to log events and record audio, if the calculated [bat] frequency is greater than 20kHz.

The log file will just consist of detected frequencies (greater than 20kHz) with associated time-stamps. The audio files will be 10 second WAV files.

The only bit that is worrying me is the microphone. How do I site this out in the open without it being destroyed by rain water?

Maybe an ordinary electret mic is not suitable, and I need to find a specialised IP65 transducer.

Raspberry Pi interface


The interface between the bat detector divider and the Pi is very simple, and I've already got this running.

The audio reaching the Adafruit USB Audio mic input is around 200mV, and alsamixer can be used to adjust the audio level as required.

My Gambas code


In my program, I launch arecord using a command to run it for 10 seconds asynchronously. So I need to determine if it is already running, to avoid launching another instance.

the process name (strProcess) is: arecord


For each audio file I need to create a unique file name which includes time, date and frequency that triggered the capture.



And within my ReadFrequency() function I now test the frequency and do this:-

Event() just stamps this info into a csv file


But where's batty?


I still have not seen or detected any bats, despite scouring the twilight skies and running my system several times during the last couple of weeks.

It is possible that the microphone I'm using only has a usable response up to (say) 30kHz. I know it has some kind of response up to 60kHz because I've been able to connect the speaker from an old cat scarer to my new signal generator and get my bat detector to squeek. I just don't know how good the response from the speaker or the microphone is.

But in previous years we have seen bats flying around against a twilight sky. This year, nothing!

I may have to package the system up and take it out to a suitable location for further testing.  ...some effort required...

No comments:

Post a Comment