dB Meter

Hello,

I'm looking for a formula/code to convert the analog input of 0 ... 1023 in dB. I didn't found the right answer in other threads.

The microphone has a sensitive of -46dB (Sensitivity (0dB=1V/Pa. 1kHz)) and the highest pressure that it could be handle with is 130 dB.
I try to set the amplify, that i get a voltage range of 0 ... 5V.

Greets
Finn

To convert to dB take the log (base 10) of the voltage, subtract an offset and multiply the result by a scale factor.

The scale factor and offset are determined by comparing to a calibrated instrument.

dB needs to have a reference level.

(power) db = 10 * log(measure/power reference level).

dB needs to have a reference level.

Yep, the reference level is the offset to be subtracted. If the calibration is done properly it will be the same reference level as used by the standard for comparison.

log(x/y) = log(x) - log(y).

Yes it is math.

But I think it is fundamental to understand that dB are not an unity like volt or ohm but a ratio, expressed in logarithmic form for convenience calculation.
A ratio has no unity.