Trying to make a mic preamp

I am trying to make a preamp for a 3-wire electret microphone for my Uno.

I tried following this schematic:

Here is a Fritzing diagram of what I have done.

Here’s a list of the parts:

1	Ceramic Capacitor	capacitance 0.1µF; voltage 35V
1	Electrolytic Capacitor	capacitance 4.7µF; voltage 35V
1	Arduino UNO (Rev3)
1	3-wire Electret Microphone*	
3	10k ? Resistor	resistance 10k?
1	1k ? Resistor	resistance 1k?
1	LM386N

*The electret mic isn’t a breakout board like in the picture. I couldn’t find a 3-wire mic in Fritzing, so I had to use that.

I am new to electronics and building circuits, and still haven’t completely figured out breadboards, so the problem could be something very simple. My dad used to do a lot of this, but that being 20 years ago he wasn’t sure what to do either.

The program I’ve been using to test the microphone is the one found here:

The input in the Serial Monitor varies between ~160,000 and ~250,000 depending on what I (re)move, so obviously I did something wrong.

Is there anything I can do to even get this thing to work? Or do I need a different mic and/or IC? If anyone could help it would be greatly appreciated.

I’ve attached the Fritzing project so someone can alter it for themselves or to show me what would work, or for whatever other purpose.


Mic preamp.fzz (6.98 KB)

Well, first... the LM386 is not a dual op-amp. It's a small power amp in a chip, meant to drive a speaker output. Find an NE5532 or TL072 -- they're both ubiquitous and cheap. :slight_smile:

OK, thanks. I’ll try to get one of those soon. Other than that, how would I have to change the circuit in order for it to work with a 3-wire mic?

I’ve had really good results with these single stage preamps, the quality of the opamp/mic make a difference. Use a socket for opamp so you can try different ones that are pin compatible.

I usually use dual opamp, as there are many more of these. Careful though, pins are different on single and dual opamps.

These give half of VCC at zero SPL:


I don’t think I understood half of what you said, but if you’re saying I can use the LM386 as a preamp, then I can pick up the correct capacitors.

But in your link for the LM386 preamp, the mic is only a 2-wire, whereas I have a 3-wire. I can’t figure out how to use a 3-wire mic in a circuit designed for a 2-wire one. Do you know how I could do it?

Yes, the LM386 will work fine, start off with that.

The LM386 has one amp, most with 8 pins have 2 amps. Take a look here, you’ll see that pins are different between single and dual.

Without getting too much into opamps, most circuits that require them, you can use any package you like, just note the pin differences for this mic preamp example.

“These give half of VCC at zero SPL:” Arduino at 5 volts, no sound will be 2.5v (or AnalogRead ~511).

The 3-wire mic shouldn’t be any different. VCC, GND, AUD out through 10uf Cap.

Stick with the DIY, you’ll learn more. Don’t buy one of those premade sensors, they only give you an ON/OFF via a comparator based on a threshold you set.

You should realize, the circuit you referred to in your original post is designed to use an op-amp IC, and the LM386 is not an op-amp... or, well... its pin configuration is not typical of op-amps. It has an internal feedback loop with a gain of 20 (which can be augmented), while an op-amp has no inherent feedback loop and will run as a comparator if left open. Since you're new to analog design, that might not mean much right now, but suffice to say it changes your approach considerably.

Using a pre-designed LM386 mic amp circuit is fine, the chip can be made to do what you want. But it is not the same thing, so you have to realize there's a difference, and pick which route you're going to take. It boils down to this: Either build from an example circuit that is designed for the LM386, or continue using your op-amp design and use an actual op-amp IC.

Regardless of which you do ....

One problem you'll have when using audio inputs is that they are AC and swing positive and negative with reference to some point. Most single-supply AC circuits use Vcc/2 (or about 2.5v on an Uno) as the reference point, with max amplitude allowing (close to, but not quite) negative peaks to 0v and positive peaks to 5v. This makes life complicated for microcontrollers, since you're looking for a DC voltage when you read the analog inputs.

One solution (if you're just interested in average level) is to use a diode to rectify the AC. This requires the signal to be capacitively coupled so it swings +/- from 0v (i.e., +2.5v to -2.5v). You would then only measure the positive peaks. However, the voltage passing through the diode has to be at least 0.7v before the diode will conduct (less with certain types of diodes -- like Schottkey), so you lose any low-level signals. You can use various biasing techniques to overcome this. Also, it's best to filter the AC (with, e.g., a 1uF cap from signal to ground) so your samples are relatively consistent. Otherwise, the value you read will depend on where in the positive waveform the sample occurred. An alternative is to take multiple samples and average them, but unless you sample over 2x the maximum frequency you expect to capture, you'll have aliasing problems. (Meet: Nyquist theorem.)

Another solution is to use Vcc/2 as the reference (not cap-coupled), and measure your distance from 2.5v. In other words, the absolute value of the signal minus 2.5v. This can cause problems with offsets unless you compare the signal level to a constant Vcc/2 reference on another analog pin, or otherwise compensate for DC bias.

Your head is probably spinning now... that's OK. Some of this will make more sense later on. Welcome to analog design with AC signals. :wink:

Oh, BTW... from what I remember, 3-wire electrets are much the same as 2-wire, just with separate voltage and audio pins. You apply V+ through a current limiting resistor to the power pin, and connect the audio pin to the coupling cap and then into the input of your whatever. It looks like you did that correctly from your image.

Yeah... that all went right over my head. Well, I figured I'd either have to use a different circuit for this IC, or get the correct IC. I'll do one of those eventually.

But yes, this is a bit more complicated than I can handle as an absolute beginner. I'll keep doing smaller things and get there eventually. :slight_smile:

Someone mentioned the NE5532 low-noise opamp, which is fine but it won’t
run off a single 5V supply, nor is it the best choice in that family as the NE5534A is
superior for low noise.

Low noise 5V-compatible rail-to-rail opamps aren’t that common, I did find the AD8656
though, which is a capable performer but SMT only…

Microphone amplifiers are all about understanding low-noise design(*), so you are
probably best finding one pre-built really unless you don’t care about sensitivity and

(*) a 1k resistor in the wrong place will dominate the noise output from a good
amplifier due to its thermal voltage noise!

Well, the pre-built ones were made somehow, weren't they? :slight_smile: If the correct parts and configuration exist somewhere, surely I could do it myself.

But you're right, it probably would be best to purchase a breakout board or shield or something, or just wait till I learn more.

Screw the shield. Why does everyone just buy shields for the simplest of things?

Noise is not really an issue here. 5532 and 5534 low noise Op Amps are used in audio because our ears are logarithmic (something 1/100th the audio power sounds 1/4th as loud) on a sliding scale, and exquisitely sensitive. A person with good hearing can, in the right very quiet room, just start to detect the air molecules bumping against their eardrums.

If you listen to music and there is a hiss on the silent parts, you are annoyed and will possibly complain. More likely, someone will get fired before the album is even made.

An Arduino's ADC is no such finely tuned detector. It is linear, and so the noise of an LM386, LM324, or some garden variety Op Amp is not even going to register.

Use an Op Amp to amplify the microphone. A 3 wire electret microphone is just a 2 wire electret microphone with the resistor added. Use an Op Amp after the preamp in a precision rectifier configuration (the Op Amp compensates for the diode's 0.7V drop) with RC filtering so the Arduino only gets a more slowly changing signal.

What is it you are trying to accomplish?

Wouldn't you hear the blood rushing through the veins in your ears before you heard the air? :stuck_out_tongue:

In my first thread on this forum I said that I wanted to make a sine wave of certain frequencies over my computer's speakers and have the Arduino react differently to different frequencies. Like at 1000Hz turn on an LED, at 500 turn it off, etc. I also had the idea of using morse code to send characters to a small LCD or some such. Either way I'd need a working mic and preamp.

Your body balances those things out pretty well, however, yes, haven't you ever heard your own blood pounding? Adrenaline gets going, heart starts pounding, and where you are is very quiet. I've heard it.

It has been my experience that about 80% of the public has destroyed their hearing by their 20s. Until very recently, I could hear a TV flyback even on a different floor of the house, most people cannot. I've always thought it was funny how much importance people put on having their stereo go from 20Hz to 20kHz, when cassette tape goes up to about 12kHz, 16kHz for really, really good tape, yet few people can really actually tell the difference.

How far away are these going to be from each other? What will the noise level in the room be?

Forget what I said about a precision rectifier.

Be aware that you won't be able to capture higher than 1/2 the sample frequency. In fact, less than that with any kind of meaningful result. The Nyquist Theorem only sets a maximum limit, in reality there are a number of factors that result in you needing a sample frequency higher than 2x the maximum frequency you are sampling.

Regarding op-amp noise level -- electret mics aren't terribly hot so the gain needs to be pretty high. There's plenty of opportunity for noise, although how much that matters depends on the strength of the anticipated signal. If the application doesn't require precise detection of tones at low SPL, then hiss is not an enormous obstacle. It would require iterative (or configurable) threshold settings though, to avoid detecting random tones in the noise.

sjheiss -- Don't give up and go with pre-built circuits. If you're doing this because you want to learn, then learn. :wink: You will fail, often. Learn to be OK with that. If everything always worked, you would never get a chance to develop troubleshooting skills, nor would you stumble across aspects of design that you wouldn't otherwise have researched. You're also going to be in over your head. I'll let you know if that ever ceases to happen. I regularly find myself in the deep end. Take in what you can and don't fret when you don't understand. It all starts to sink in after a while, and things that were complete gibberish before start to sound familiar, and then comprehendable, and then obvious.

I'm sure many here would be willing to walk you through this, but if you're interested, I'll volunteer to explain what I know about handling AC signals. I can't guarantee it's all perfect advice (NE5532 won't work on single-supply +5v, huh? Didn't think to check that, since I tend to keep a stash of TL07x and OPx134 for my own use) but if we keep it going in this thread, I'm sure others will catch my errors.

So, is this something you want to understand? Or are you content with finding a working circuit to build, and then moving on?

Thank you both very much for your help. But I am more interested in the software side than hardware, so right now I don't feel the need to know exactly what's going on in the hardware, as long as the software I make works and can use the hardware. :slight_smile:

So thanks again for your offer, but I think for now I'll just stick to a breakout board like this one, or use a circuit someone else has made.

You got it. Of course, we'll be around if you ever feel adventurous. :wink: Good luck with the project.

Ok. Thank you! :slight_smile:

Hi, did you manage to get the lm386 amp to work?
The problem that I can see in the fritzing diag is that you have not connected pin 4 to gnd.
Tom... :slight_smile:

No, I haven't tried anything with it since I made this thread. Do you think connecting 4 to ground would do anything?