gktechnology
Posts: 1
Joined: Sun Sep 30, 2012 9:25 pm

Bat detector

Sun Sep 30, 2012 10:17 pm

Having fun with my Pi. Now I want to make it do something spectacular.
I want to make a bat detector. Bats echolocate using frequencies up to around 130KHz so obviously ordinary microphones are out of the question.

What I want to do is mount some omni directional high frequency mics outside running back to the Pi. I would like to display a frequency graph showing real time input. Also I would like to be able to choose a frequency range and step this down into the human audio frequency range so I can hear the bats.

I have no idea where to start with this and I'm relatively inexperienced with electronics but I'm eager to learn and think this would be a great project.

Anyone got any ideas to give me some direction?

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: Bat detector

Sun Sep 30, 2012 11:19 pm

This is a fantastic idea!

A cursory google gives this link: http://www.bats.org.uk/pages/bat_detectors.html

it seems there are a number of commercial bat detectors on the market - I would try and identify what sensor they use and buy one.

I guess the challenge is to interface this with the Pi and process the information it gathers.

You could use a hetrodyning technique, to try to tune in to a set species' frequncy in real time, but then you would only find what you are looking for...

I wonder if there might also be a way to record (ultra)sound for later analysis using software such as is mentioned on the above website.

either way the Pi could provide a cost effective portable solution...
Ostendo ignarus addo scientia.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12344
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Bat detector

Sun Sep 30, 2012 11:24 pm

As for the hardware needed, this isn't a job for a PI, except maybe drawing the graphs. The actual hardware would normally consist of several opamps, and frequency counters. An arduino style microcontroller would be a better fit for the hardware required than a desktop system running a multitasking OS like Linux.

I would start googling for some pointers, there are already many hardware solutions for bat detectors, specifically the electronics magazine elektor has published some recently.
Here is a good link http://bertrik.sikken.nl/bat/articles.htm

A suitable microphone would be an ultrasonic transducer as used in range finders.
A source for those could be Parralax. http://www.parallax.com/

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: Bat detector

Mon Oct 01, 2012 12:12 am

Not sure I agree.

An adaption of this circuit could perhaps be interfaced with the Pi http://pw1.netcom.com/~t-rex/BatDetector.html via GPIO as the author states:
Ultrasonic sources processed by the detector convert to sounds like geiger-counter clicks and chirps.
Which is digital information of sorts.

I guess you would need an additional filter perhaps incorporating a schmitt trigger between the circuit and the GPIO.

I envisage testing this without captive bats or a bat simulator could be a head-ache!

You might find that you would also have to address timing/priority issues with Linux - but other people have managed to work around this - http://www.raspberrypi.org/phpBB3/viewt ... ic#p184961 / http://www.raspberrypi.org/phpBB3/viewt ... =panalyzer
Ostendo ignarus addo scientia.

Hoagie
Posts: 119
Joined: Sun Sep 23, 2012 7:19 pm

Re: Bat detector

Wed Oct 03, 2012 11:44 am

I made a bat detector a long time ago and keep thinking about making a new one. My sensor was a 40KHz Ultrasonic receiver intended for remote control applications. The bandwidth of it was only 2 KHz which helped for my design.

I amplified the signal, then used an analogue switch to sample at a 38kHz rate. Then smoothed the output before sending it out via an earpiece. This sample rate and signal rate interfered (aliased) deliberately and gave me an output signal at around 2kHz for a 40kHz input. It's also a very simple circuit to make, and can run for ages from a PP3 battery.

A lot of bat detector designs use standard audio microphones and pass them through high pass filters. This gives a very small, but I'm told usable signal in the right frequency band.

I'm in the UK, where most bats are below 100kHz, so if I was looking into this now, I'd see if I could get an analogue to digital converter sampling at 200kHz to record the whole thing. Anyone know how to get signals like that into a Raspberry PI? USB soundcard maybe?

I'd also think about real time frequency division. I don't know if the PI has the horsepower to do that, but I'd have a go. There are some existing algorithms to do frequency division, probably available with a bit of googling. An FFT, a bit of data shifting, then another FFT springs to mind. If all that works, I can't see any reason not to make it portable.

If anyone does this, let us all know. It seems like a great use of the PI.

bmonticola
Posts: 1
Joined: Wed Mar 06, 2013 1:10 pm

Re: Bat detector

Wed Mar 06, 2013 1:25 pm

Hi all,

I've been pondering something like this for a while but, not being nearly techy enough at this point to follow though with ideas, and having little time, I've not actually progressed very far!

I need to learn the basics of C++ I think...

I do, however, know a bit about bats, detectors and how they're used.

Frequency division detectors use an ultrasonic microphone (often electret or Mems) and divide the incoming signal by a factor of 10 or thereabouts (10 makes things easier afterwards...) so a Soprano Pipistrelle echolocating at 55Khz produces an audible signal to us at 5.5Khz (we can hear up to 17Khz I think).
The actual sound is a bit rubbish for determining species - you can determine a species of bat from various call charateristics, from the 'peak frequency' (where most of the energy of the call is put), the repetition rate (faster flying bats echolocate more slowly, as the 'call' is linked to wingbeats to save energy (think hummingbirds flying slowly and Sparrowhawks flying fast) and some other features I won't bore you with.
The beauty of frequency division is you can then save these calls using a .wav records (mp3s aren't high enough quality) and look at them on a computer after (Wavesurfer being one free programme you can set up to do it).
Batbox do a detector called the 'baton' which is fantastic at this. You may be better off making a bat detector using electronic methods and using the Pi to mess about with sound files (storage of bat calls, perhaps, using a GPS to georeference each recorded call perhaps? Make a log of the strongest frequency of each call? dunno! It would be cool to have the detector in your hand, and have it bluetooth a load of useful info into your pocket you could download later!

Heterodyne set up an internal frequency which you can alter, and compares the inputted signal to internal frequency to play the difference. The output is a much better sound, which more qualities you can analyse (by ear only Im afraid) such as tone, duration etc.
More advanced heterodyne (which you may be able to achieve using a Pi or arduino) could possibly split the incoming signal, so you can mess about with your frequency dial with one split, and the detector will automatically scan through a load of frequencies and tell you which is the strongest (its useful to be able to move the dial for species id reasons I can explain at length if anyones in the least bit interested!). Again, this info could be recorded for later, and georeffed so you could plonk where you found bats onto google maps or something.

In terms of finding a source of ultrasonic sound old tv's used to emit at about 30khz (I dont know about flat screens, I can check tonight) but its much more fun to head out and look for bats!

I don't know if this helps or not, all the best!

User avatar
raspberrydt
Posts: 57
Joined: Mon Jan 21, 2013 3:09 pm

Re: Bat detector

Mon Apr 15, 2013 1:32 pm

Hi guys, I went into bat detectors short time ago, and would like to do something with a Pi.

Lots of cheap electret mics have no problem going up to 100 or 150 kHz, even if the specs say they do 15 or 17 kHz. These mics cost about 0,50 to 3,- € so I would just buy a few and test them with a 40kHz transmitter, see what they do.

The Pi shoul be powerful enough to do real time mixing and visualisation, and together with a nice 2.8" touch LCD and a battery pack you should be able to have some hours of fun in the woods.

But how to get the mic signal into the Pi? USB sound card will surely cut off frequencies above 20kHz. Anyone knows if the limits can be adapted?

ADC connected to the I2C bus is way too slow. If I want to get up to 100 or 150 kHz signals without much analogue electronics the ADC should operate at about 0.5 to 1MHz. I believe 8 bits are enough, still leading to 4-8 Mbps pure data.

efficacy
Posts: 2
Joined: Thu Feb 07, 2013 12:45 pm
Location: Ipswich, Suffolk, UK
Contact: Website

Re: Bat detector

Mon Apr 15, 2013 2:48 pm

I have been playing with this idea for a month or two.

My current most likely idea is to use a low cost development board such as a Freescale KL25Z or K20D50M to do the fast A2D input, convert/filter/compress the data and send it over a fast link (probably USB or SPI) to the Pi for processing, analysis and user interface, but I'd love to hear from anyone else making progress in similar or different directions.

Have a poke around on my site http://raspberryalphaomega.org.uk/ to read more of my ramblings about this.

Frank.
Frank Carver - http://frankcarver.me/ - http://raspberryalphaomega.org.uk/

User avatar
cyrano
Posts: 714
Joined: Wed Dec 05, 2012 11:48 pm
Location: Belgium

Re: Bat detector

Mon Apr 15, 2013 5:47 pm

I've recorded bats and other animals' high frequency sound. Some electrets can go up to 60-70 KHz. Over that range, you won't get much usable input because of the low S/R and the fact that the mic is seldom in the ideal location. By far the best thing out there is the Dodotronic USB mic:

http://www.dodotronic.com/acoustic-devices/ultramics

It doesn't bring frequencies down to the human hearing range, but that can easily be done in post treatment, on the Pi. It's not cheap, but you don't need a second mortgage on your house either. I've never tested it with the Pi, tho.

And if you think bats are hard, you should try mice. They also range up to 120 KHz and usually babble at a very low level. They can be loud too, but I've never had the chance to record mice fighting.

User avatar
raspberrydt
Posts: 57
Joined: Mon Jan 21, 2013 3:09 pm

Re: Bat detector

Tue Apr 16, 2013 7:00 am

Nice thing. Pricey, sure, but very nice. Thanks!

g4bch
Posts: 8
Joined: Mon Oct 01, 2012 12:06 pm

Re: Bat detector

Wed Apr 17, 2013 12:50 pm

I've had a digital bat detector project in the planning and very slow build stage as time permits for some time now, but it is being overtaken by technology. The idea is / was to use a PIC32 for AD conversion, processing and storing the data for later analysis.
My earlier efforts with heterodyne detectors using eletret microphones and 40kHz resonator have worked but not been too good. Senscom 600 transducers are much beter but need high voltage bias.

As for the number of AD bits needed 8 may be OK for a walk in the woods, but for anything more serious the more the merrier. I have spoken with one of our local bat recorders who has done some serious bat survey work https://sites.google.com/site/parkhurst ... oject-blog and from his comments 16bit at 500kSps would be about right. His expensive recorder is I think only 14 bits at 300kSps and the FFT resolution for species identification is getting a bit limited. Some species have very similar calls and it need a good dynamic range to tell them apart.

It may be over the top but to make a good detector / recorder it looks like it needs to be able to cope with those data rates together with GPS data for logging. It also needs to be able to cope with each of digital heterodyne down conversion, time expansion and frequency division.
Something like this would be very similar to a detector costing $ks.

Peter

Rickthurmond
Posts: 2
Joined: Fri Nov 22, 2013 8:37 pm

Re: Bat detector

Sat Nov 23, 2013 3:41 am

I built a bat detector in the analog realm about fifteen years ago. A 40 kHz microphone was connected to an amplifier then to the AM input of an oscillator chip. My idea was to tune the oscillator around until the down converted bat sounds came out of the speaker. Never worked well around bats though. I think my problem was that the 40 kHz microphone had a very narrow band, so unless the bat was making noise right at 40 KHz, the microphone didn't pick it up. Even 45 kHz was probably out of range.

So, I've been looking for an affordable wideband ultrasonic microphone ever since.

I would like to build a new one (after getting a usable microphone) using the RPi. I could imagine a search mode where you are taking sound records from the microphone and doing an fft to find out whether there's a signal anywhere. I think you would have to sample at 200 kHz to find signals up to 100 kHz. Let's say the fft finds a good signal at 60 kHz, and you want to convert that to 2 kHz. You could then generate an array of a sine wave at 62 kHz, and then start taking data records and multiplying them by this sound wave. If you were taking records 2 ksamples long, and multiplying them by your 2 ksample sine wave, you'd have to do it every 10 milliseconds. Can a Raspberry pi go that fast? Can we hijack the GPU and do it in OpenGL or OpenCL? This array multiplication gives you sum and difference frequencies, or 2 kHz and 122 kHz (I think that is called heterodyning). Play it back over the microphone, and you should hear the bat!

A couple improvements if the RPi has enough computing power. Normalize the frequency response of the microphone first, and filter/decimate the audio signal down to 44 kHz or whatever you want to play it at. Maybe in the above example the array should be at 58 kHz instead of 62.

So, can anyone recommend a wide-band ultrasonic microphone that costs less than a car? A 12-bit A/D converter that can convert at 200 kHz and place the data in arrays on the RPi?
Rick

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Bat detector

Sat Nov 23, 2013 10:37 am

I think you going to have difficulty finding hardware capable of sampling at 200KHz and being compatible with the Pi, perhaps a DSO pocket oscilloscope would be a better alternative - http://seeedstudio.com/wiki/DSO_Nano_v3
As for microphones I have no idea which works best for bats but the following page would suggest using MEMS Ultrasonic Acoustic Sensor or an Electret / Condenser - http://www.durhambats.org.uk/dets.htm

Just out of curiosity which species of bats are you looking for, it seems each species use different frequency ranges??

Richard S.

Rickthurmond
Posts: 2
Joined: Fri Nov 22, 2013 8:37 pm

Re: Bat detector

Sat Nov 23, 2013 6:39 pm

The mems sensor looks like the one to use. The specific one specified is no longer made, but maybe a little searching will find a replacement. I agree that it will still be difficult to get a 200 kHz signal into the pi.

I'm new to this, so I wrote a python program to generate an array with a signal, given a signal frequency and a sampling frequency. I was about to write a function to multiply two arrays, but I just found out about numpy so I've downloaded that and I'll try using it.

pinik2
Posts: 3
Joined: Sun Jun 24, 2012 11:43 am

Re: Bat detector

Sat Apr 26, 2014 10:11 am

With the release of the Wolfson audio card for the pi audio recording at 192kss is now easily do-able.
I have recorded some pipistrelles in the garden with frequencies so far recorded up to around 65kHz.
This is using the on-board DMIC microphones.
Having the odd occasional problem of overruns on record.

hystrix
Posts: 56
Joined: Mon Jan 07, 2013 12:44 pm

Re: Bat detector

Mon Apr 28, 2014 11:37 am

pinik2 wrote:With the release of the Wolfson audio card for the pi audio recording at 192kss is now easily do-able.
I have recorded some pipistrelles in the garden with frequencies so far recorded up to around 65kHz.
This is using the on-board DMIC microphones.
Having the odd occasional problem of overruns on record.
Can you share some more details...I've just got the Wolfson audio card and am also planning to record bats in my garden.

I'm new to ALSA and sound recording on the Pi, and would like to do something with Python. So far I have only found out how to record for a set duration - I would like to have an "event" driven recording stop (e.g. GUI pushbutton). How are you starting/stopping the recording?

Many thanks.

pinik2
Posts: 3
Joined: Sun Jun 24, 2012 11:43 am

Re: Bat detector

Mon Apr 28, 2014 9:11 pm

Hi Hystrix

I am not doing anything clever at the moment

Sorry I can't help you with the event/button to start recording I am doing everything from an ssh terminal command line. I use arecord to start a fixed length capture and view the results on my laptop using audacity. Luckily I have a bat detector which helps me know when to start a recording. The results in audacity look like this.

Image

Regards
Nick

hystrix
Posts: 56
Joined: Mon Jan 07, 2013 12:44 pm

Re: Bat detector

Sun Jun 08, 2014 10:27 am

I had some success recording bats this week-end with my Pi and Wolfson audio card!

Details of my Pi Bat recorder and sonograms can be found here:

http://www.afraidofsunlight.co.uk/weath ... p?page=bat

pinik2
Posts: 3
Joined: Sun Jun 24, 2012 11:43 am

Re: Bat detector

Thu Aug 21, 2014 9:25 pm

hystrix

Very nice write up.
May I ask what you used as an external microphone.
Also your sonograms are very clear, What software did you use to create them?

Thanks
Nick

hystrix
Posts: 56
Joined: Mon Jan 07, 2013 12:44 pm

Re: Bat detector

Fri Aug 22, 2014 5:36 pm

Hi Nick,

The external microphone is an electret type, with a high frequency response.

The software I use is a mixture of Audacity for initially extracting bat calls from the wav files, and producing sonograms, plus BatExplorer from Elekon for sonograms and analysis.

keviom
Posts: 3
Joined: Fri Sep 05, 2014 12:43 pm

Re: Bat detector

Mon Sep 08, 2014 12:30 pm

Hy Hystrix,

I have just come across your article and found it interesting as I am currently looking for a recording / analysis equipment to add to my heterodyne detector and move on to the next level of species identification.

I have just a some questions which I am hoping you might be able to answer.

Were you able to see and analyse the amplitude of the recorded calls?
Is this is a frequency division , time expansion or full spectrum type recording?
Is there a multiplying factor for the calls, or did audacity show them at the frequency they were actually sending at (the Pipistrelle calls, August 2014 seem quite low frequency which is why I ask)
Finally, how do you power the Pi and the microphone when out and about please (I'm a newbie to the Pi world)

Sorry to ask so many questions, but if this works like I'm hoping it could become very useful in our local bat group.
Thanks in advance

hystrix
Posts: 56
Joined: Mon Jan 07, 2013 12:44 pm

Re: Bat detector

Mon Sep 08, 2014 4:11 pm

Hi keviom,

The amplitude, or intensity, of the calls can be seen in the sonogram since it is represented by the intensity of the colour. What is of interest is the peak frequency, which can easily be analysed using Audacity. Here's a Common Pipistrelle from one of my recordings, and the peak frequency:

Image

Image

The recordings are full spectrum, and using the Wolfson Audio Card are at the maximum 192kHz sample rate. This allows analysis up to 96kHz which is good enough for most UK bats (Lesser horseshoe is around 110kHz).

Audacity shows the actual recorded frequency, since it is full spectrum. The "low frequency" call that I think you are referring to are social calls, which are louder are are usually at a lower relative frequency in comparison with echolocation calls.

I power the Pi from a "Power Bank": https://www.modmypi.com/raspberry-pi-ac ... power-bank

Hope these answer your questions. A question for you: where is your local bat group?

Let me know how you get on if you use your Pi to record bats.

Regards,

Hystrix
keviom wrote:Hy Hystrix,

I have just come across your article and found it interesting as I am currently looking for a recording / analysis equipment to add to my heterodyne detector and move on to the next level of species identification.

I have just a some questions which I am hoping you might be able to answer.

Were you able to see and analyse the amplitude of the recorded calls?
Is this is a frequency division , time expansion or full spectrum type recording?
Is there a multiplying factor for the calls, or did audacity show them at the frequency they were actually sending at (the Pipistrelle calls, August 2014 seem quite low frequency which is why I ask)
Finally, how do you power the Pi and the microphone when out and about please (I'm a newbie to the Pi world)

Sorry to ask so many questions, but if this works like I'm hoping it could become very useful in our local bat group.
Thanks in advance

keviom
Posts: 3
Joined: Fri Sep 05, 2014 12:43 pm

Re: Bat detector

Mon Sep 08, 2014 8:48 pm

Hi Hystrix,

Thanks for getting back so quickly. Sorry, my mistake I didn't mean amplitude it was my misreading my notes from a recent training session. It was the oscilloscope type view so you can measure the inter pulse interval and duration of each call easily.

My local bat group is the Manx Bat Group (Isle of Man).

Time to start ordering all the bits now to try making a detector

BTW did you try a MEMs microphone or did you go straight for the Electret type?

Keviom

hystrix
Posts: 56
Joined: Mon Jan 07, 2013 12:44 pm

Re: Bat detector

Tue Sep 09, 2014 6:55 am

Hi Keviom,

I haven't found a way of easily measuring call duration and inter-pulse interval using Audacity. I use BatExplorer for that, and get good results:

Image

There is other software available like BatSound, which is very good but also quite expensive (for a hobbyist).

I started off using the on-board MEMs microphones with some success, but changed to an external mic when I put it all in a plastic case.

Note that the current Wolfson Audio Card is not compatible with the newer B+ Raspberry Pi.

Regards,

Hystrix

keviom
Posts: 3
Joined: Fri Sep 05, 2014 12:43 pm

Re: Bat detector

Wed Sep 10, 2014 4:30 pm

Hi Hystrix,

Thanks again for taking the tome to answer. Just one more question (I hope). Did you have to supply any power to the microphone. I have been looking around and there seems to be differing opinions as to whether you need it for an electret (and / or MEMS type) or if the device you plug it into, in this case the Wolfson board, supplies the power.

Keviom

Return to “Graphics, sound and multimedia”