# Arduino Forum

## Using Arduino => General Electronics => Topic started by: Rustie0125 on Jan 07, 2014, 03:06 pm

Title: Arduino dBSPL meter
Post by: Rustie0125 on Jan 07, 2014, 03:06 pm
Hi Guys

I am busy with a project that has a few phases, the first phase is the most difficult one in my eyes and i would really like some guidance on how and where to begin.

I want to use a mic, pre amp and Uno to accurately measure dBm from a speaker. at the risk of sounding very naive
what is the formula to calculate the dbm from a mic out put of 2.7 to 5 v ? i would prefer to stay away from the IC that spit out dbm for you as i need to know what the calculation is for the next phase

any help would be great
Title: Re: Arduino dBSPL meter
Post by: Rustie0125 on Jan 07, 2014, 03:36 pm
is this the fomula
Formula: dB = 20 x Log (volts1/volts2) or 20 Log (2.5/5)?
Title: Re: Arduino dBSPL meter
Post by: KeithRB on Jan 07, 2014, 04:50 pm
Over what frequency band? What weighting curve? You can take a bunch of samples and rms them, but the arduino is severely band limited and will chop off a lot of the signal typically used for this measurement.
Title: Re: Arduino dBSPL meter
Post by: Rustie0125 on Jan 07, 2014, 05:48 pm
well it wil be used for bird sounds and the bird sounds range from 50hz to 200 khz as far as we know, but we do not want to record we only want a decibel reading
Title: Re: Arduino dBSPL meter
Post by: KeithRB on Jan 07, 2014, 07:45 pm
Do you have a precision microphone in mind that will give you accurate SPL for a certain voltage?

Arduino cannot directly digitize a 200kHz frequency. Your best bet is to buy a meter - Radio Shack used to have a good one - and hack into the meter to get a DC reading that the Arduino can handle.
Title: Re: Arduino dBSPL meter
Post by: polymorph on Jan 07, 2014, 09:02 pm
dBm (note capitalization) is a measure of power where 1mW = 0dBm. You are looking for (as you do say in the subject line) dB SPL, which is something else.

But dB SPL is based on how loud a sound is to a human. So 0dB SPL is set by the threshhold of hearing of a human, and changes according to frequency. That is the "weighting scale" mentioned by KeithRB. However, at the peak or best response of the human ear, that is 20uPa (20 micropascals) of sound pressure.

http://www.phon.ucl.ac.uk/courses/spsci/acoustics/week1-2.pdf

http://www.engineeringtoolbox.com/decibel-d_59.html

Keep in mind that 10x the voltage in a measuring circuit is 100x the power, hence 10x the voltage is +20dB above the reference.

For your purposes, you could use that over the entire range you wish to cover. You are going to have a devil of a time finding a transducer (microphone) that can cover that with a flat or at least known/measurable response curve.
Title: Re: Arduino dBSPL meter
Post by: DVDdoug on Jan 07, 2014, 11:39 pm
So.... Normally you'd build the thing and then calibrate it using test signals and a known-good SPL meter as a reference.

There are companies that calibrate scientific equipment, but proper calibration would cost you about as much as purchasing an SPL meter.   If you just need something "useful", but not necessarily scientifically-accurate, you can calibrate it yourself with test tones (or pink noise) and a known-good SPL meter.

Quote
calculate the dbm from a mic out put of 2.7 to 5 v ?
You can look-up the microhone sensitivity spec.   That will give the voltage (in millivolts) for a given SPL level.    Then, you have to compensate for the preamp gain.   The specs for an ordinary recording/performance mic are just a guideline.  You can get a calibrated instrumentation microphone that comes with the actual test results for that specific unit.   This (http://www.parts-express.com/dayton-audio-emm-6-electret-measurement-microphone--390-801) is the least expensive calibrated mic I know of (\$50 USD).  They generally go for a LOT more.

Quote
...bird sounds range from 50hz to 200 khz as far as we know,
Is that a typo?   200kHz would be a problem.   You'd probably need a 2nd special ultrasonic transducer for that, and since it's above the normal audio range, you'd have to devise a method of calibrating it...  That would require some "serious science"...

The good thing is that the Arduino itself doesn't need to go to 200kHz.   You can use an analog "averaging circuit" to convert the high-frequency AC signal to varying DC.    For my (uncalibrated) meter lighting effects, I use a Peak Detector circuit (https://www.circuitlab.com/circuit/y453h7/precision-active-peak-detector/).    You'd probably want something where the DC follows the average level, rather than the peaks.  That can be done with a low-pass filter (or something like a low-pass filter).   But, that also means that any weighting has to be done in analog, since there is no frequency-information going into the Arduino.

If a bird actually makes sounds up to 200kHz, I would guess it's also making lower frequencies at the same time.  Those lower frequencies will mask (drown-out) the supersonic frequencies anyway.    You'd have to do spectral analysis to detect the high frequencies.....   A single "loudness" measurement isn't going to do it.   And unless you are in a soundproof studio, there will be lots of other ambient sounds masking those frequencies (and maybe even drowning-out audible bird sounds).   High frequencies are also greatly attenuated in air, so if there is much distance, the supersonics won't be measurable.

What bird goes down to 50Hz?    An ostrich?
Title: Re: Arduino dBSPL meter
Post by: KeithRB on Jan 08, 2014, 12:47 am
The trilling/warbling would be at lower frequencies, so you would have a higher frequency tone amplitude modulated by the 50 Hz.
Title: Re: Arduino dBSPL meter
Post by: polymorph on Jan 08, 2014, 01:13 am
Actually, if you AM modulate, say, a 50kHz tone with 50Hz, you don't get a 50Hz tone. You get 49.950kHz, 50kHz, and 50.050kHz.
Title: Re: Arduino dBSPL meter
Post by: Rustie0125 on Jan 08, 2014, 06:05 am
WOW guys

thank for the great response !  one thing i can see now is that i have clearly miss judges of how complicated this is. let me explain what my project has to do and maybe you would get a better idea on how to do it.

First of tracking is not possible as birds can not carry anything more then 25g

the Background
I am studding  the territorial behavior   of a bird called South african koraan. our studies have show that these birds hand there territories down from generation to generation rather then being owned by dominate males.

the problem
these birds habit is normally very thick and you can barley see 5 meters into the bush from the road. but you always always hear them when driving through their area.

the idea
we want to be able to listen to the sound get a decibel reading and calculate the distance from where we are to where the bird is. Crazy ? well the rest is easy. we know the birds natural decibel level at 1 meter is around 85 decibel and we know in the thick bush we can hear the bird up to 100 meters away.   so i have two of the three factors needed to calculate the distance. and i can do it using a linear graph but if i can make this work the next stage would saving the Decibels and distance on a SD card. and final stage would be to take a GPS reading from where recorded and calculate where the bird was heard.( we can already point out direction)

so where does that leave me now? is a very expensive mic required for what i want to do ?

[EDIT]
50hz to 20Khz is more then enough
Title: Re: Arduino dBSPL meter
Post by: polymorph on Jan 08, 2014, 06:09 am
Does the microphone really need to pick up all the way to 200kHz, or is up to around 20kHz enough?
Title: Re: Arduino dBSPL meter
Post by: polymorph on Jan 08, 2014, 06:18 am
Oh! That is a rather huge difference. Really huge difference.

50 to 200Hz isn't a problem. How much of a problem is ambient noise?
Title: Re: Arduino dBSPL meter
Post by: Rustie0125 on Jan 08, 2014, 06:24 am
that is good to know ! would 1 -6 khz also be doable ? ( other bird) setting on device ?
ambient noise is generally insects and the bird sound over powers insect sound by far.

come to think of it what good would the device be for anything outside human hearing range. since we first ID the bird by hearing it and then taking a measurement. so if the device does what a human can hear it will be sufficient
Title: Re: Arduino dBSPL meter
Post by: Rustie0125 on Jan 08, 2014, 06:37 am
the Mic i am planning on using is this mic. it very small size and has a op amp built in. (100x)
the mic sensitivity is (0dB=1v/Pa)
Title: Re: Arduino dBSPL meter
Post by: polymorph on Jan 08, 2014, 06:57 am
Did you mean 1kHz to 6kHz?

Title: Re: Arduino dBSPL meter
Post by: Rustie0125 on Jan 08, 2014, 07:07 am
yes 1khz to 6khz .
http://netram.co.za/1097-electret-microphone-breakout-board.html  . under documents there is data sheet for the op amp and one for the mic. but i am still not clear on what the output voltage range is.
Title: Re: Arduino dBSPL meter
Post by: polymorph on Jan 08, 2014, 07:19 am
What you need is a log detector. It accepts a signal and outputs a voltage that is a function of the logarithm of the input power.

They are meant for RF, but a few go down to DC. The AD8307, for instance. It has a 92dB dynamic range.

There are a LOT of samples of interfaces from the AD8307 to an Arduino. Most are for RF work, but to the Arduino side, it makes no difference what frequency is going into the AD8307.

So you just need sufficient amplification to put the signal you desire to measure well inside the dynamic range of the AD8307. You may have to do some cut-and-try and some work with a 'scope, but I suspect that electret microphone is a good start.
Title: Re: Arduino dBSPL meter
Post by: Rustie0125 on Jan 08, 2014, 07:49 am
I was hoping to stay away from IC's but it seems it s the only way.
i will see if i can order one.

Question i have is is the mic i have order has the op amp built in will it still word with this chip or do I need to just use a normal mic on the chip
Title: Re: Arduino dBSPL meter
Post by: polymorph on Jan 10, 2014, 06:12 am
One 8 pin IC and a handful or two of passive parts sounds good to me.

You'll need amplification from the mic, anyway, so use the one with a built-in 100x Op Amp. You can always put in a level control after it, you'll need some way of calibrating it, anyway.