Electret microphone amplifier

zx-sound-self

Amplifier for an electret microphone that can be used to detect sound with an Arduino or other microcontroller. The op-amp used is a TLC272 that is pin compatible with a number of other dual op-amps such as the LM393 the LM358 or the OPA2344 and OPA2345.

IC1a is used as a non-inverting amplifier. It offers a higher impedance as the inverting amplifier. The gain of the non-inverting amplifier is determined by 1+R4/R1 and is 40dB (100x). If desired a trim pot can be used for R4.

In most cases it is possible to DC couple the circuit. However in this case it is necessary to ensure that the non-inverting has a DC path to earth for the very small input current that is needed. This can be achieved by resistor, R2 in the diagram. The value of this may typically be 100 kOhms or more. If this resistor is not inserted the output of the operational amplifier will be driven into one of the voltage rails.

When adding a resistor in this manner the capacitor-resistor combination forms a high pass filter with a cut-off frequency. The cut off point occurs at a frequency where the capacitive reactance is equal to the resistance. This is expressed in the Formula 1/2πRC. For the used combination it is =16Hz.

The output on pin 1 is at best a sinus wave and though microcontrollers do not really like those or any other odd shaped wave, when fed to their ADC input that does not make a difference. However, if  the output of IC1a is fed to an ADC there will be very strong fluctuations in the reading and as such the signal is not really representing the total sound pressure. We do that  with op-amp IC1b that is used as a comparator with a reference voltage on the inverting entrance. When fed with  5Volt, the Voltage on the inverting entrance will be 72mV ((5000/69)*1)
As long as V- < V+, Vo will be low, but when the sound level rises above 72mV, IC1b will make the output go high.
With a gain of 100 in IC1a, a voltage off 720uV from the microphone would be enough.  The Voltage build up over C3 is depending on the number of times the Output goes high and thus is an indication for the sound pressure.

electret-pcb

The PCB is quite simple. The convoluted area above the double op-amp is to either insert a resistor, or an upright trim pot that can be inserted facing, or facing away from the IC.
There are 4 extra components in comparison with the circuit. Those are 2 LED’s and 2 resistors. These give an indication of the Output voltage as well as the supply voltage.  They are optional however:
P1040773e

There are many commercially available electret breakout boards for the Arduino (or other micro controllers). One of them is the Sparkfun breakout board:
electret-sparkfun Sparkfun had a bit of a rocky start in this area with their BOB-08669 and they replaced it with the BOB-09964, the difference between the two being some changes in resistor and capacitor values.

The Sparkfun board is centered around 1 op-amp, the OPA344 that is used as an inverting amplifier. The gain is determined by R5/R4 and is 40dB (100x). The input high pass RC filter cuts off frequencies below 10Hz. The RC network with C3 and R5 cut off above 13 kHz. The original BOB-08669 would cut off too high and it’s impedance was too low (as can be expected from an inverting op amp). The cut-off  for the low pass filter can be calculated from xc=1/2πRC, in which xc being the reactive capacitance. With the given values of 12pF and 1Mhz the low pass is determined at 13.2kHz. The high pass around C1 and R4 gives a cut off of 3.3Hz (so not 10Hz as stated).

R2 and R3 give an off-set adjustment centered around half voltage (2.5 Volts).

Though the new board is an improvement over the old one, still a lot of people experienced problems with it. It did not really change in design, just a few R and C values were adapted.

Dealextreme  offers a board based around a 393. It has an audio out and a digital out for if the signal comes above a certain threshold. It is the KY-037 from Keyes and has a 12 turn potentiometer to set the threshold. It is rumoured to have low sensitivity.

Freetronics board
The Freetronics board is also based upon the TLC272. It offers an audio output and a sound pressure output with visual indication. Here the peak detection on pin 6 of the IC is set to 71 mV and the gain of the first opamp is set to 100
mike_module_freetronics

Using a Single Opamp
electret-741

Using a single op-amp of course is also possible and this time we will use the inverting pin of an LM741. The gain = R4/R3 =1000=60dB.
D1 and D2 form a voltage doubler, rectifier and peak detector.
C3 and R5 form an RC delay for the analog entrance of the Arduino

 

Using the LM386
Although the LM386 is primarily aimed to drive a speaker, it can be used as a microphone pre-amp. results with it however have been less than satisfying.

Using the LM358
The LM358 gives better results than the LM386.

Testing
The following code can be used to easily test the workings of the amplifier in combination with an Arduuino. The code reads the input 10.000 tmes and then prints the min, the max and the spread

/**
 * Measures the voltage on an analog pin over a ~1s period
 * of time and sends the Min, Max and Diff (Spread) values 
 * over Serial.
 *
 * Author: 
 * Dimitar Kovachev, http://lowvoltage.wordpress.com/
 *
 */
const int analogPin = 0;

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

void loop() {
  int mn = 1024;     // mn only decreases
  int mx = 0;        // mx only increases

  // Perform 10000 reads. Update mn and mx for each one.
  for (int i = 0; i < 10000; ++i) {
    int val = analogRead(analogPin);
    mn = min(mn, val);
    mx = max(mx, val);
  }

  // Send min, max and delta over Serial
  Serial.print("m=");
  Serial.print(mn);  
  Serial.print(" M=");
  Serial.print(mx);  
  Serial.print(" D=");
  Serial.print(mx-mn);  
  Serial.println();  
}

32 thoughts on “Electret microphone amplifier”

    1. I might not have been entirely clear. With ‘digital port’ I meant ‘computer port’ this can be an analogue as well as a strict digital port.
      If you connect the output to an analogue port you can chose the level to which yr program will react, if connected to a a digital port, the amplificatiuon needs to be such that yr port will see the desired level as a 1 or a 0
      In many applications you will see a capacitor between exit and mass to store a charge that will represent an average volume rather than a very short loud volume

      1. it is 34x28mm
        against my expectation I did not upload the PCB design. I will do that one of these days

      1. ah ok. I understand. yes that works. I didnt know I had uploaded it before

  1. I used the Sparkfun breakout board to record audio. The audio levels are really low. How do I increase the volume of the recorded audio?

    1. I am not sure if you use the old or the new sparkfun board, but it should give a gain of about 100x.
      Many people have had issues witj it. I am not sure what it is that you are using it for? connected to your Arduino or purely for an audio project?
      The Old board (BOB-08669) surely has room for improvement, but also the new board can be improved.
      The microphone in the sparkfun board isnt really that sensitive. The datasheet for the microphone used in the breakout board says that the typical sensitivity is rated at -44 dBv (about 6.3 millivolts at 94 dB sound pressure level). With a gain of 100 the output at that level will be .63 volts.
      A Few things you can do is to replace the input capacitor with a 10uF capacitor, or if that is easier, put a 4.7 uF capacitor in parallel. The ‘+’ side should go to the microphone. If you have the new board: put a 10k resistor in parallel to the 10K input resistor. If you have the old board, replace R5 with a 200k.
      That way your amplification goes up to 200.
      Hope that helps

  2. I have been trying to build the lm741 circuit you have posted and my outputs from the program keep declining down to 0.

    Min=62 Max=76 Delta=14
    Min=57 Max=71 Delta=14
    Min=53 Max=67 Delta=14
    Min=49 Max=63 Delta=14
    Min=46 Max=59 Delta=13

    Min=1 Max=12 Delta=11
    Min=1 Max=12 Delta=11
    Min=0 Max=11 Delta=11

    Have you had any luck with the circuit by chance?

    1. sorry to hear that. I just quickly put the circuit together just now on a breadboard and it seems to work fine.
      Can u expand a bit on yr findings because I am not quite sure what you mean with the findings you posted.

      1. I am just curious, what values did you get when you built the lm741?

        I built the circuit using a UA741CN. I am somewhat new to building electronics circuits, so I apologize if I am unclear in my findings. Basically, if I take out C3 and R5 from the circuit I get some steady readings (very low readings, but steady). But when I have them in the circuit, the output on the serial monitor of the arduino will start as I posted earlier and then work it’s way slowly down to 0 across the mn, mx, and delta. I think it’s a capacitor issue on the output but I am not 100% sure what values I should be getting on my output to A0 of my arduino. I would assume somewhere between 400-500 as the circuit splits the 5V from the arduino into 2.5V+ and – no?

        If this is still unclear please let me know what I could expand on. I’d really like to get this circuit working so I can try the uSpeech library 🙂

        Thank you!

      2. OK I understand now what u mean.
        Well with regard to the output, as there is no dc coupling the output ideally is zero.
        The amplification of the opamp is determined by R3 and R4 and is 1000
        with a signal of say 2 mv u would get 2000mV on the output of the 741 this wld be superposed on the dc output but that is taken out by the coupling capacitor C2. the 2000mV however is a sinus and the ADC cannot really work with that and also, this is a sound pressure detector so u are interested in sound of a certain level over a certain time. The circuit behind C2 basically makes yr sinus into a DC level.
        unless there is a constant sound input the average on the Output to yr Arduino will be a bit less than 2 Volt which will give a reading of about 400.
        the program takes a 1000 readings, so if the soundlevel into the microphone is varying over that period, the average on the output will go down.
        So.. what kind of sound did u offer to the mike and for how long?
        as u measured a constant level (as i understand) without C3 and R5 there are a few possibilities: not having to charge C3 will indeed make the output a bit higher, but the fact that it the output is going down means that either there was a lot of variance on theinput… or u have a leaking capacitor.
        I would start with putting R5 back in because that should not be the problem.

        In th emean time you sent another messagethat may shed some more light on the problem.
        Obviously you do NOT connect the +5V from the Arduino to the Non-inverting pin. Why would you even think that should be done? The only cannection that must be made between the Arduino and the soundboard is the connection between the output and the analog input of the arduino AND between the two 0V lines.

        You also need to feed both with 5Volt. Th easiets ofcourse is to do that from the same source. In that case you have 3 connections between this circuit and the Arduino: +5V, analog and 0V

      3. Also, did you connect the +5V of the arduino to the non inverting pin of the lm741 as well as the VCC+? and then the ground of the arduino to the VCC-? I don’t know if that is supposed to be done :S.

      4. Zach, I overlooked yr last question on connecting the Arduino Vcc.
        I am a bit surprised. What makes you think you need to connect the Arduino Vcc to the non-inverting entrance of the 741? Nowhere in the circuit it says it should.
        If you feed the 741 with 5 Volt, you can tie the Vcc of the Arduino and of the 741 together.
        If you would then make the completely random connection to the non-inverting entrance, you would effectively short R1

  3. Okay, I think I am using the wrong type of circuit! I need to use the microphone to listen to voice input, not a certain sound level over time. Any recommendations on a circuit to do so?

    Thank you for your help!

  4. Hello, thanks for the detailed comparisons.

    I have a stm32f103 robot project (3.3v), and I’m looking for a microphone which is sensitive enough for far-range voice recogntion (let’s say normal talk about 10 meters away), less circuit noise.

    Honestly I’m a little confused with so many circuits. Could you please kindly tell me which one is best? Then I can buy the pieces and make one myself.

    Hope your reply and many thanks in advance.

    1. That is a difficult one.As you say there are many different circuits and i do not know all of them. The circuit I published is not suitable as it is for sound level detection.
      Fur voice recognition you will probably be ok with a MAX4466 based circuit, but the 10 meters will be a challenge. I think you may need to go for something based around a MAX9814.

      1. Thanks for reply.

        Last night I found a work around. As my poor sensor (similar to Dealextreme’s one) has only 10x (20DB), I added a 5cmx5cm paper behind like a radar. Then it gave me 20x now without multiplying the internal circuit noise.

        I think with other materials or shapes, I should have a 30x maybe. I will test it later.

      2. that is good, but I presume that with a robot, directionality might be an issue so where it might help you in one direction it may harm you in the other

  5. I tested it and it can amplify sound from all the directions.

    I guess that it uses some kind of resonance instead of reflection.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.