Help needed for programming arduino to read voltage output from Mic?

Hey,

I want to program arduino to read the voltage output from a electret microphone. Attached is the circuit I use to amplify the signal from micrphone (which I have tested using an oscilloscope and works fine). Also attached is the simple program used to read the output from microphone and the output on serial monitor.

The problem is that even without any input to the microphone the serial monitor keep showing me outputs (there is no noise in the room that can give such a high digital value). What could be the problem and solution for this?

Thanks.

Complete Circuit Latest.png

In an ideal world you woul expect a reading of 512 with no sound input.
What do you get, a higher or lower voltage would indicate a DC offset on the op amp.
This can be rectified by AC coupling the stages of your filter.

Considering that the range of values possible is from 0 to 1023, a value around 200 probably does represent relatively quiet. Is there a problem with this?

What actual range of values did you measure on the scope?

So in my circuit i used R2 = 240 ohms and R1 = 510 ohms. So that means it is biased at 2.88V. Is this the reason why the ADC keep printing values on serial monitor?

The other problem is when I scream at the microphone there is no increase in ADC output values on serial monitor? When I checked with the oscilloscope it gives me a maximum value of 2.5Vpp.

So, is it a problem with the coding? Or circuit?

In an ideal world you woul expect a reading of 512 with no sound input.

Why is this? Is it because because when you use 5V supply and you bias at 2.5V? In my case I am using 9V biased at 2.8V. So does the ADC reading hold true in my case?

Is it because because when you use 5V supply and you bias at 2.5V?

Yes.

So does the ADC reading hold true in my case?

Yes silence is still 2.5V which is a reading of 512.

The other problem is when I scream at the microphone there is no increase in ADC output values on serial monitor?

You will not see an increase in readings when you input sound. What you will see is in increase in the range of readings you get.
So silence should be 512.
A small sound might have reading between say 412 and 612
A full sound will have readings anywhere between 0 and 1023

My biasing is working well. But, there is no increase in the range of readings when I scream or play loud noise near the microphone. Guess, something is definitely wrong. Is there a possible problems that might cause this, so I can narrow the reasons.

s there a possible problems that might cause this, so I can narrow the reasons.

Well the op amp isn't working, have you looked at the output with a scope?

Also you don't need both of those two capacitors in series on the input to the mike one will do. (any one is better than both)

I checked the circuit again with oscilloscope and it works fine. The output is between 0 to 5V and the amplification works. I get a max Vpp of 2V. Attached is the output from oscilloscope and the output from arduino serial monitor when I connect the ciruit but with no input to the microphone. As you can see the graph is an analog wave without any input, which I don’t have a clue why.

Thanks

With Amp @ 15cm.BMP (15.8 KB)

Voice - Arduino Result.xls (25.5 KB)

The numbers you get and the waveform you have do not match up, simply they are not the same thing.

It looks like you are recording the signal from a floating analogue input, that is, an input with nothing connected to it.
Check that the amplifier is connected to the analogue input you are measuring.

As a double check, connect a pot in place of your amplifier and see if that reads OK on the input pin and that the input pin has not been blown.

The analog pin was connected to amplification circuit output. Just tried testing whether the analog input pin was working fine by using this example (http://arduino.cc/en/Tutorial/AnalogInput) and the pins are perfect too. So, what could it be, what am I not seeing?

Just been thinking why its not working and going through the code. Could it be that the microphone is taking voice as input and the baud-rate set using Serial.begin() is too low for voice. I set it to 9600, could it be a reason? If so, what value should be used?

Any baud rate is not going to be fast enough but that would not stop you from getting random numbers in the right range.
Are you sure your grounds are connected together, it sounds like there is no reference point for your audio signal.

I wonder what you are hoping to do with this data.

Looking at your code you are only taking a reading less than 3 times per second.

The delay(300) means wait 300 milliseconds before taking a reading.
The stock time for analogRead to complete is 111 uS

Your oscilloscope is taking readings much faster than that.

As the input is an audio signal when you actually take a reading it could be at any point in the waveform.
Because of this you will in effect get a random value each time.

I have a circuit (electret mic + opamp) whose voltage output will sit at 0V until it hears a sound. You can clap, or make noise and the voltage will increase proportional to the noise level. I've been experimenting with it as a sound trigger. It can pick up a pin drop. If you're interested I can post the diagram.

If you're interested I can post the diagram.

I am.

John_S:
I have a circuit (electret mic + opamp) whose voltage output will sit at 0V until it hears a sound. You can clap, or make noise and the voltage will increase proportional to the noise level. I've been experimenting with it as a sound trigger. It can pick up a pin drop. If you're interested I can post the diagram.

This looks interesting to me as well. When the output level rises how long does it stay at that level?

So in my circuit i used R2 = 240 ohms and R1 = 510 ohms

Values of resistors are too low, they form first order HPF with 1 uF capacitor, cut-off freq. in ultrasound area.

Here’s the circuit I use. Like I said, I’m experimenting with it as a sound trigger. Mic1 is just a generic electret mic I got off ebay. Be sure you get the polarity correct. C5 and R2 provide an envelope follower (basically how long the output stays high before it drops off). With the values quoted, it the output will drop off fairly fast, I’m guessing around 0.1 sec.

Increasing C3 will have the effect of more amplification (i.e. you will get a higher output voltage).

If you need serious amplification, connect a 10uF cap between pins 1 and 8 of the opamp. I found doing so will increase the noise of the output, but if you need to catch a the sound of a cat purring in the next room it would be worth a shot.

Run the output to an analog input. With a loud clap, you should see the analogRead values spike in the 350-400 range

Electret Audio Amp.png

It is not really a very suitable chip to use as a microphone pre amp, it is basically a power amplifier with a limited gain.
You would be much better off using a proper op-amp.

Increasing C3 will have the effect of more amplification (i.e. you will get a higher output voltage).

C3 does not increase the gain, it just increases the coupling, the gain is controlled by a capacitor between pins 1 & 8.

For the circuit previously attached in this thread, how do you connect to arduino uno.

  1. The output from circuit goes into analog pin.
  2. Arduino ground is connected to ground.
  3. And do I need to connect the AREF pin to a 5V supply through a resistor. Or by default arduino takes reference as 5V? Because the circuit is not powered by the arduino uno's 5V pin.