Electret microphone not giving expected output

Hello! I am very new to electronics so this could be a very simple fix, but I have a circuit involving an electret microphone that looks like this:
and yes, I triple checked that my microphone was hooked up properly. Anyways, when I wrote some code for the Arduino,
int soundPin = A0;void setup() { // put your setup code here, to run once - Pastebin.com (the code so you can see how this was outputted)
this was the output I was greeted with:
Imgur: The magic of the Internet
Imgur: The magic of the Internet
By the way, I wasn't speaking into the microphone in image 1. Also, image 1 was using A6 on my Arduino and image 2 was using A0 on my Arduino, just to test that it wasn't something wrong with my port. A0 was also doing the same thing as the first image, I was just demonstrating that the output is very random and clearly broken. I was using the Arduino nano as well.
I think it is something wrong with the circuit I am using, but I could've broken my board too. I don't think the code is wrong, but it is a possibility. I am not using an amplifier circuit either so that could be another reason. Anyways, I hope someone here can help me fix this issue. Thank you!

but I have a circuit involving an electret microphone that looks like this:
Imgur: The magic of the Internet

Microphones usually need a preamp so without one you might have to shout directly into the mic, or stick it in front of a 100W guitar amp to get a small reading. :smiley: Summing like that will increase the numbers, but it's a lousy way to "amplify".

Also, you need bias circuit (a pair of ~10K resistors, plus the existing capacitor) to keep the analog input from floating to an unknown value.

I'd recommend getting a microphone board [u]like this[/u] or similar, which has a built-in preamp and bias circuit.* (That particular one doesn't have adjustable gain and it doesn't have a whole lot of gain so you might still have to shout.)

And then, maybe try-out the code from my [u]World's simplest Lighting Effect[/u]. It "flashes" an LED on when the sound is louder than the short-term average and turns it off when quieter than average. That's really just example code to get you off the ground...

  • SparkFun publishes the schematic if you want to see what the circuit looks like, but it's really not worth building yourself.

Condenser Microphone

As you can see, you can buy better quality microphones.
The one you have probably cheap.
You get what you pay for.

  1. The analogue pin if 'floating' for DC because of the capacitor,
    so the A/D can already return any value between 0 and 1023 without any sound (usually about 350).

If you leave the cap in, then connect a 100k resistor between analogue pin and ground and a 100k resistor between analogue pin and 5volt, to force the pin mid-voltage (~2.5volt on a 5volt Arduino).
You can also just remove the cap, and connect the mic directly to the pin. In that case you might have to adjust the 1k resistor for mid-voltage on the mic/pin.

  1. you sample audio once every 20ms (adding 100 samples + delay).
    That effectively makes a 25hz low pass filter. All audio is averaged out.
    Try to print after each single analogue reading.

Please read the 'how to post' sticky, so you know how to post images/code inline on this site.



If you just want to 'detect' sound level (over a threshold), then you could use a peak/peak detector.
Example code attached (untested).

const byte soundPin = A0;
int soundValue;
int minValue, maxValue;
int threshold = 5;

void setup() {

void loop() {
  minValue = 1023; // reset
  maxValue = 0; // reset
  for (int i = 0; i < 500; i++) {
    soundValue = analogRead(soundPin);
    if (soundValue > maxValue) maxValue = soundValue;
    if (soundValue < minValue) minValue = soundValue;
  soundValue = maxValue - minValue; // calculate peak/peak
  if (soundValue >= threshold) {

Electret microphones need amplifying by a factor of around 100 or more - a microphone pre-amplifier is required.

Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile:

Can I suggest this circuit;
A smaller C1 and some 10K to bias the analog input to 2.5V or 1024/2= 512 out of the ADC.

Tom.... :slight_smile:

You can suggest that circuit, but its missing the required amplifier so it won't solve the whole problem, just centre the milli-volt signal at 2.5V