Electronic – Convert Digital and Analog values to dB SPL

audiomicrocontroller

I am trying to create a sound level meter. I want to use an analog MEMS microphone (INMP510) and a digital microphone with I2S output (SPH0645LM4H). The sensitivity of the INMP510 is -38 dBV and for SPH0645LM4H is -26 dBFS. I am using a PIC32MZ2048EFG100. The ADC module has 12 bits and the voltage for the ADC are 0 and 3.3 V.

I have read this post (How to convert Volts in dB SPL) but I can't find the specifications of the gain of the analog microphone, so I don't know if I am correctly calculating the dB SPL.

Also for the digital microphone, I have no idea how to convert the digital values to dB SPL.

Can somebody help me with mathematical formulas?

Thank you in advance

Best Answer

The INMP510 microphone sensitivity is -38 dBV with a sound pressure level of 94 dB at 1 kHz. -38 dBV is 12.6 mV RMS. So if you measure 12.6 mV RMS then your SPL is 94 dB. If you measured twice that voltage then your SPL will be 6 dB higher. If you measured half the voltage your SPL would be 6 dB lower.

Do you know how the decibel works with rising and falling signals?

For the digital microphone, it has a specification of -26 dBFS for the same 94 dB SPL. FS refers to full scale and full scale appears to be 18 bits if you read the small print. So the RMS value it would produce is 26 dB down on a full scale of 18 bits but remember this is likely to be peak to peak. In other words a full scale signal would be +/- 131072 counts.

So, what do you do with the stream of digital numbers after conversion? First you subtract the midpoint because that is the mean numerical value and represents a large dc offset that ruins the calculation. So now you are dealing in signed integers. To calculate RMS (because that's what you need to do), square each value, accumulate many values then divide by the number of values you accumulated. Finally take the square root and that gives you RMS.

However, make sure you accumulate enough samples or there will be an error term. The alternative is to try and be clever and calculate just as many samples as you need to cover one period of the sound source frequency.

Take note - once you have signed integers, the sign becomes unimportant because of the operation of squaring.

Can you take it from here?

Related Topic