Db measurement MAX9814

Hi!

I am working with an Arduino mega2560 board and a max9814 sensor.
What I would like to do is measure the dB present in a room.
I know the gain of the sensor (60dB, which I can vary depending on how I connect the Gain pin) and the sensitivity of the sensor (= -44 which in V/RMS would be 0.00631).

const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;

void setup() 
{
   Serial.begin(9600);
}


void loop() 
{
   unsigned long startMillis= millis();  // Start of sample window
   unsigned int peakToPeak = 0;   // peak-to-peak level

   unsigned int signalMax = 0;
   unsigned int signalMin = 1024;

   // collect data for 50 mS
   while (millis() - startMillis < sampleWindow)
   {
      sample = analogRead(A3);
      if (sample < 1024)  // toss out spurious readings
      {
         if (sample > signalMax)
         {
            signalMax = sample;  // save just the max levels
         }
         else if (sample < signalMin)
         {
            signalMin = sample;  // save just the min levels
         }
      }
   }
   peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
   double volts = ((peakToPeak * 5) / 1024) * 0.707;  // convert to volts
   double first = log10(volts/0.00631)*20; // The microphone sensitivity is -44 ±2 so V RMS / PA is 0.00631
   double second = first + 94 - 44 - 60; // The microphone sensitivity is -44 ±2
   Serial.println("misurazione: ");
   Serial.print(second);
}

In your opinion, is this an acceptable solution?

Thank you very much for your advice.
Alberto.

I do that a lot but I use my phone, it was an app that cost $0.99 a few years back. I also purchased a audio spectrum analyzer app for the same price. Both work very well. It looks like it might work but with out knowing all the hardware details etc I cannot be sure.

I'm guessing you didn't try it...

```
double first = log10(volts/0.00631)*20; // The microphone sensitivity is -44 ±2 so V RMS / PA is 0.00631
   double second = first + 94 - 44 - 60; // The microphone sensitivity is -44 ±2
```

No...
At 94dB SPL and 60dB of gain you would (theoretically) get 6.31V. That gives you a dB calculation (first) of 60dB, So far, so good.

But of course, the dB SPL (second) should be 94dB. (Take 44 out of the calculation.)

You can combine all of the constants and simplify to first +34dB.

You can only get 5V peak-to-peak so you can't actually read 94dB SPL.

double volts = ((peakToPeak * 5) / 1024) * 0.707;  // convert to volts

RMS is 0.707 x peak, so cut that in half for peak-to-peak.

You can make a "functional" SPL meter, depending on the application but there are several issues with making a "real" SPL meter.

Note that you are calculating peak SPL and that won't match a real SPL meter unless you're reading constant tones. Here is the code for an SPL meter I made. It's also "imperfect" but there are lots of notes & comments that might be helpful.

ok thank you very much!
I'd like to ask you one more thing... do you think this sensor would be good for understanding noise pollution precisely and accurately?
because I also found this other sensor: gravity sen0232..... do you think this one might be better?

Don't you think noise pollution is only in the ear of the listener? Some think Harley exhaust sound is beautiful, while I think it is pollution!

thanks, very nice.....
mine is a serious question anyway

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.