Go Down

Topic: Converting Envelope Readings From Sparkfun Sound Detector To Decibels (Read 3772 times) previous topic - next topic

PopiPenguin

Hi guys, Intermediate-level Arduino user here.

So for a project at school, me and my friends are building an Arduino-based system that detects sound around the library using 3 Sparkfun Sound Detectors (https://www.sparkfun.com/products/12642?_ga=1.33746913.1707451727.1447920879). It'll display the decibels on a web page every 5 seconds and once the noise reaches 40db, it'll automatically tweet a notification to the librarian.

The code itself is finished except that the reading I am getting from the envelope isn't in dB as far as I know, it's Amplitude. Is there any mathematical formula that one can use to convert this into decibels?

Thank you!

Magician


PopiPenguin

Thank you so much! I did see one of your posts in a previous thread but I had to ask as I think we're using a different sound sensor. For reference's sake, what is the scientific basis to this? Is this a standardized equation?

Magician

https://en.wikipedia.org/wiki/Sound_pressure#Sound_pressure_level
Mathematical equations don't bother  what kind of sensor you have.It's always abstract. Sensor defined only in term of sensitivity, linearity and dynamic range.

PopiPenguin

https://en.wikipedia.org/wiki/Sound_pressure#Sound_pressure_level
Mathematical equations don't bother  what kind of sensor you have.It's always abstract. Sensor defined only in term of sensitivity, linearity and dynamic range.
Oh, thanks! "dB = 20 x log10(Amplitude)" converts the value from the envelope reading into decibels right?

Grumpy_Mike

You have to ask yourself decibels with respect to what? In this case it is with respect to the lowest possible amplitude reading, that is 1.
Normally decibels are represented as a ratio between two values so it is more accurate to say:-
dB = 20 x log10(reading / reference reading)  

Slack jawed people often say a sound level is at 40dBs where as they might mean 40dBm ( decibels over a milli watt ) or dBW -> decibels over a watt or even over the limit of sound a human can perceive.
http://makingnoiseandhearingthings.com/2012/06/25/what-is-the-loudest-softest-highest-lowest-sound-humans-can-hear/

DVDdoug

Quote
Oh, thanks! "dB = 20 x log10(Amplitude)" converts the value from the envelope reading into decibels right?
That's NOT quite right...   You need a reference...

dB = 20log(Amplitude/Amplitude reference).   For example, if your reference of 0dB is defined as 100, then 1000 is +20dB and 10 is -20dB.

Since (I assume) we don't know the sensitivity of the SparkFun board, you'll need an SPL meter to calibrate the meter you're building.

Quote
and once the noise reaches 40db
The first thing to do is make sure you can get a usable reading at 40dB SPL...  That's rather quiet...

Here is an example - You play a test-tone and adjust it to 70dB SPL on the known good SPL meter.    If the Arudino's DAC is reading 500, you know that corresponds to 70dB SPL.   That can be your reference, or you can calculate a new reference...   

If the sound level changes and the DAC reads 1000, we can calculate the dB difference. 20log(1000/500) = +6dB.   That means we are now at 76dB SPL         If you read 250, that calculates to -6dB, so you're at 64dB SPL.


P.S.
After you get this basically working, you'll probably want some averaging.   Take a look at the Smoothing Example.

You should also know that real SPL measurements are also usually weighted, but that's probably not worth doing.   







Magician

Quote
Quote
Oh, thanks! "dB = 20 x log10(Amplitude)" converts the value from the envelope reading into decibels right?
That's NOT quite right...   You need a reference...
Well, I was trying to avoid unnecessary confusion. According to this:
https://en.wikipedia.org/wiki/Logarithm#Product.2C_quotient.2C_power_and_root
than dB = 20 x log10(Amplitude) should be corrected to dB = 20 x log10(Amplitude) - zero_offset.
From practical point of view, you just substituted as zero_level what ever level arduino measure in quite environment,  and subtract. It would include surround sound noise, mic+ preamp noise, adc inaccuracy, etc.

Grumpy_Mike

I remember some years ago a long thread about a project that monitored the noise in a school canteen, and when the noise reached above a certain level a sign saying "sush" or some such message was lit up.

The upshot was that they could find no measure that corresponded to the perceived loudness of the real sounds.

Go Up