Arduino Uno Sound level project help.

I have an Uno, an Adafruit Max4466 mic, and an Adafruit Max9814 mic. I am basically trying to create a project that, for the most part, will not be hearing anything, but when a sound does occur, I need to be able to measure the length of the sound and if the length of the sound exceeds a predetermined amount of time, then trigger an action.

As my early stages of working on it, I have been trying to get the mic to output sound levels to the serial plotter, so I can then take that and use that as a tool to help create sound level triggers as well as length triggers. but I have had issues with getting very unsteady readings from the plotter even when the room is dead quiet, the graph is still quite full of noise.

I have been using the Max4466 mic, wired up to the 3.3v power on the Uno(as this was noted as the "quietest output" on the Arduino) and the output hooked to A0 on the Uno. I have tried adjusting the POT on the mic to help with sensitivity, but I noticed no change. In addition to that I have tried using averaging filters of the readings, multiplying the input by itself for nonlinear scaling as recommended by a previous post on a different forum, and tried multiplying the value by a "sensitivity value to make the highs of the wave higher and the dips lower, all of these to no avail.

Any general guidance or ideas would be greatly appreciated. My knowledge of electronics is somewhat rudimentary, as is my knowledge of programming, but I am a quick learner and listen well. This project is very important to me, and it has been at a standstill for several weeks now, so I am in dire need of a breakthrough. Thanks in advance.

Do you know what “kind” (general frequencies) of noise you are getting? Have you tried making an “analog” filter to get rid of some noise that would be outside the audible spectrum? You can make a rough filter very easily with parts you may very well have on you anyway. Voltage spikes can also be leveled out with capacitors. Not sure if I am fully understanding your issue, but those may be worth a look.

The MAX9814 has auto-gain, so that makes it useless for measuring loudness.

The other mic should work.

You are measuring/sampling a wave so even with a constant tone the measurements will "look random", except louder sounds will have some higher positive and negative peaks. If you don't understand why the readings look random, check out the [u]Audacity website[/u] for a little introduction to how audio is sampled.

Note that the Arduino can't measure negative voltages so most "microphone boards" are biased at half the power supply voltage and the signals go below and above that bias. At 5V silence should read about 512 (half of the 1023 range) and with a 3V supply silence should read about 307. You can subtract-out the bias to get the positive and negative values.

Of course, your room isn't really dead silent...

Since the waveform is positive half the time and negative half the time, the average is always zero. (Or if here is bias, the average is equal to the bias.)

There are a couple of ways to deal with this... The easiest thing is to sample in a "fast loop" for about 50 milliseconds (or longer) and find the peaks. Or, you can take the average of the absolute values or the average of the positive samples (ignoring the negative samples).

You might have more success if you used something like this sound detector board.

Instead of just having an audio output, the signal is processed further to give an 'envelope' output and a 'gate' output.

The three outputs can be used independently, one of the others may be more appropriate for your intended use.

The schematic of the board is shown here, it may give you an ideas for an op amp circuit to assist you.