Infineon / IM69D130-Microphone-Shield2Go

Examples for Infineon's MEMS microphone based evaluation board IM69D130 Microphone Shield2Go for Arduino.
MIT License
7 stars 6 forks source link

Calculation of dBSPL #4

Closed too-ns closed 2 years ago

too-ns commented 3 years ago

I'm trying to calculate sound pressure in dBSPL scale.

I extended the example soundPressureLevel to get the dBSPL by using the following conversion formulas: dbFS = 20 * log10(abs(maxSample - minSample) / DIGITAL_MAX) where DIGITAL_MAX is 524288 (for a signed 20 bit integer). The sample width is 20 bits which is configured using I2S.begin(). For dBSPL conversion, dBSPL = AOP + dbFS where AOP is 130 for IM69D130.

My issue being, when checking for the values in serial plotter/monitor with a reference sound level meter, it seems to be off by 10 dB. I'm using the IM69D130-Microphone-Shield2Go with XMC2GO and using Arduino IDE for compilation and serial data monitoring.

Please comment on the validity of the approach that I've used and suggest a way/resource to proceed to calculate dBSPL.

EktaNashine07 commented 2 years ago

Hi @too-ns

To calculate dBSPL, it should be

dBSPL = 130 – (20*LOG(ABS(PCM_VALUE)/524288));  This is only valid for 20-bit system,

It is not recommended to convert from a single PCM value to a dBSPL value. dBSPL is an RMS value so it should be computed over a full waveform. If you are measuring the peak PCM level of a sine signal then you can roughly compute the RMS by subtracting 3dB. Computing for a random waveform you should first window the signal, calculate the RMS value of that signal within the window and then convert that result to dBSPL.

Some other information: https://en.wikipedia.org/wiki/Sound_pressure#Sound_pressure_level

Best Regards Ekta