Electret Microphone Sensor

Hi,

Is there anyone who has already worked with Electret Micrphone Sensor https://www.sparkfun.com/products/9964? I need to detect the noise in my room, so I wired the sensor simply to my Arduino (5v, GND, Analog Pin 0), and I am getting random values (70 to 130) which are independent to the existing noise.

Thanks, Mohammad

This records the audio waveform, these are very fast. Do you have a delay or a print in your code? If you do then you are unlikely to see the numbers change with the sound. The louder the sound the more big and small numbers you get, the quiter the sound the more mid range numbers you get. It sounds like you want to measure the envelope rather than the sound itself, is this true?

According to the comments on the Sparkfun page https://www.sparkfun.com/products/9964, I could solve the problem. Somebody recommended to write a tight loop (e.g. 100ms) to get the min and max values. The difference between the two will give us the volume (sound pressure) during that time.

and I am getting random values (70 to 130) which are independent to the existing noise.

When you say "noise", are you talking about background noise, or are you saying that you get numbers between 70 & 130, no matter how loud the sound?

Do you have a multimeter to measure the voltage out of the microphone board?

Did you connect 5V? You should have 3 connections - 5 Volts, ground, and signal.

I don't have that board, but looking at the schematic, there are a pair of 10k "bias resistors", that should set the output to half the power supply (2.5V). With a voltmeter/multimeter, you should measure about 2.5V DC coming out of the board.

And, since the full range of the ADC is 10-bits (1023 decimal), you should get a reading of around 512 with no sound (assuming the default 5V reference). There will normally be some jumping-around (i.e. "noise"). If all of your readings are around 100, something is very wrong ... You knew that already.

The bias is added because the audio is AC (the voltage goes positive and negative), but the Arduino cannot accept negative input voltages.

Since the audio signal is AC, you should get readings (approximately) centered around 512. With loud sounds, you may get signals that nearly go down to zero, and nearly up to 1023.

Somebody recommended to write a tight loop (e.g. 100ms) to get the min and max values. The difference between the two will give us the volume (sound pressure) during that time.

Since audio is a waveform that's constantly changing from moment-to-moment, if you want to digitize it you have to sample it. For example, CDs are sampled 44,100 times per second. Twice per cycle, the (unbiased) audio crosses-through zero.

Depending on your application, you may want to sample it at a continuous rate (like a CD), and/or take an average, or sample and save the peaks. I have an application where I calculate a 20-second [u]moving average[/u] by taking a reading once per second and putting 20 values in an array. (Once per second is very-slow sampling for audio!)

If you decide to take an average, you'll need to take the absolute value, or ignore the "negative" readings below 512, because the average should always be around 512. The mathematical average of any normal (unbiased) AC waveform is zero.

Actually, I never measured what you asked. You are absolutely right about the sampling rate. For a better measurement, I should change the rate. Thanks.

smaj:
According to the comments on the Sparkfun page https://www.sparkfun.com/products/9964, I could solve the problem. Somebody recommended to write a tight loop (e.g. 100ms) to get the min and max values. The difference between the two will give us the volume (sound pressure) during that time.

Yes that is a poor solution because it requires a lot of processing time. If it were me I would put the output of the card to the anode of a diode, Put the cathode to the analogue input and then wire a 10K resistor from the analogue input to ground and put a 0.1uF capacitor across that resistor, that is also between the input and ground. Play about with the capacitor value it might need to be up to 2.2 uF.

Do remember that a peak audio signal has little to do with the perceived loudness of a sound.