LM358 microphone amplifier
After the unconvincing performance of the LM386 mic amp, another design is put to the test. This time, based around a LM358 operational amplifier.
Operational amplifiers are high-gain voltage amplifiers. There’s a huge amount of information available on how to use them and the guide I followed is TI’s“Op Amps for Everyone”. The schematic is an “Inverting AC amplifier” (A.3.18, p. 424). From the equations there, the voltages on the two outputs are:
- V_OUT_UC = – V_IN * R5 / R4 + VCC / 2 = – 100 * V_IN + VCC / 2
- V_OUT = -100 * V_IN, as the C3 capacitor is blocking the DC component
(V_IN is the voltage at pin 2)
Op amps do not provide a lot of output power. In-ear headphones can be driven from V_OUT, but it’s unlikely that a LM358 will power even a small speaker. For a microcontroller, connected to V_OUT_UC, output power does not matter, only voltage does.
LM358 sound sensor performance
As in the LM386 mic amp setup, V_OUT_UC is connected to Arduino’s A0 pin and the Min-Max sketch is uploaded. By using different R5 resistor values (10K, 47K, 100K), gains of 10x, 47x and 100x are achieved:
|10x||510 ~ 512||2||307 ~ 735||428|
|47x||505 ~ 517||12||17 ~ 754||737|
|100x||500 ~ 525||25||7 ~ 755||748|
Pretty good! The noise level in silence increases linearly with gain. Moving from 10x to 50x gain gives a good increase in the maximum output swing. Pushing the gain to 100x provides only a minor improvement. Overall, the 50x setup gives the best noise vs. output swing results.
The LM358 does not have a true rail-to-rail (0V to VCC) output. The datasheet specifies an “output voltage swing 0V to (VCC – 1.5V)”. This means that when VCC = 5V, the largest possible analog reading is in the 715 – 750 range. In order to get an wider output range, a better op-amp should be used.
Current draw was 1.52mA, in the 100x setup
|C1||10uF||Microphone coupling capacitor|
|C2||100nF||Power supply decoupling|
|R1||1 ~ 10K||Microphone load resistor|
|R2, R3||10K||Voltage divider: 1/2 VCC|
|R4||1K||Gain = – R5 / R4|
|VSS||3 ~ 30V||Supply voltage|
- EAGLE schematic [.sch]
- Min-Max sketch code [.pde]
- LM358 Datasheet [.pdf], STMicro
- “Powering microphones” by Tomi Engdahl
- “Op Amps for Everyone”, Texas Instruments
- A similar LM358 mic amp design
Posted on May 21, 2011, in Electronics and tagged amplifier, analog, Arduino, LM358, microphone, op-amp, sensor. Bookmark the permalink. 55 Comments.
Thank you very much for a good picture of the board and a straight forward write up, it helped me alot!
You’re welcome, Chris!
Hi, I am tried to test, followed your instructions here, but I have having problems with noise, please give me any suggestion ?
Can you describe your setup in more details? Like, are you using the audio output V_OUT or the microcontroller output V_OUT_UC? How is this noise showing up – unstable Arduino readings or poor-quality audio? What is the op-amp gain set to?
As general suggestions, you should double-check all connections. Are the power rails (+5V and GND) properly routed over all breadboard sections? Then, check if the polarized components (mic and caps) are correctly oriented. Finally, you may try lowering the value of R1, the microphone load resistor, down to 4.7k or 1k
Hey, this is exactly what i was looking for!
Thanks for all the info!
Hi Dimitar, thanks for a great article.
I’m planning a similar circuit, but getting audio input from a guitar jack.
My guitar signal is up to 600mV peak-to-peak (for the loudest possible chord strum). What values of R5 & R4 would you recommend? I believe I need less than 10x gain to fit within 5V range. Am I right?
Also, can you explain the role of R1? Will I need one for the guitar input?
For a 10x gain, you can leave R4 at 1k and reduce R5 to 10k. The R1 resistor is part of the microphone setup, you won’t need it in the general case.
Please keep in mind that the LM358 op-amp is probably not the best choice for quality audio applications. This amplifier may work as a proof-of-concept, but you may want to search for better, specialized guitar amplifier schematics.
is it possible to get the Digital O/P from the circuit to drive digital circuit what ill be the o/p voltage
LM358 does not have a rail-to-rail output and with a +5V supply, its maximum output voltage is ~3.5V. This may be too low for some digital inputs to register as a logic “1” / “HIGH”. A comparator (like LM393) or a Schmitt trigger IC may be used to reliably convert the output to digital.
Thanks for this post, it has been a geat help!!
I got best results with slightly different values for resistors and capacitors:
R4 = 0 (Removed it completely!)
Power supply is 3.3V and I also have a low pass filter on the power.
I’m using the V_OUT_UC connected to to an ATMEGA and eventually converting this to audio. Voice is loud and noise level is low enough.
Why is R4 needed at all in this circuit?
With R4 shorted out (i.e. R4 = 0), the op-amp would work in what looks like a comparator mode, i.e. with maximum amplification. The output would swing to either ~0V or ~3.5V even for slightest changes in the input signal and I’d expect the output to be clipped and distorted.
But I’ve never tried such a setup and if it works fine for you – that’s great!
Dimitar – It did not behave that way. I agree that according to the formulas it should (with an ideal opamp), but it didn’t happen this way in real life. It had the effect of increasing the gain but not to a full swing between GND and VCC.
Hi I want to connect output to the XBee but ADC range of XBee is 0-1.2V what i should do sir ?
and if i want to select frequency in range 40-300 Hz could you guide me ?
For scaling down the output voltage from 0-5V to 0-1.2V you can use a voltage divider at the output, with a pair of 10k & 3.3k resistors (or a similar pair with a 3:1 ratio). The voltage across the 3.3k resistor will be 1/4 of the output voltage.
I am trying to do a small voice recognition circuit using an arduino mega2560 i bought earlier last year. Are there any changes that i will need to make to this circuit for it? I tried but it gave me no results. I checked everything thrice, still. Should i use a pre-amp circuit as well? if yes, which one would you suggest?
Dear Dimitar, thanks a LOT for your design, it works perfectly, you saved my day !!
Thanks for share.
How do I design this circuit for “differential microphone”?
Thank a lot!
No idea about the ‘differential microphone’ circuit, sorry
Hi Dimitar, Great writeup. I am trying to build a hearing aid for my elderly father. I found an exisiting preamp mic http://www.dfrobot.com/wiki/index.php?title=Analog_Sound_Sensor_(SKU:_DFR0034) that can directly well to a headphone, but I am short on the gain a little. I found the schematic here, can I increase the gain by changing the R7 value from 100K to 150K, and how does will affect the sound? and how does this schematic compare to the example you used, it seems that it is using both stages here..
the schematic is here http://www.dfrobot.com/image/data/DFR0034/V2.0/Analog%20Sound%20Sensor%20SCH.pdf
The LM358 most likely does not have enough output power to produce a loud sound when using headphones. It’s not a matter of more gain, it’s a limitation of the device. I’d go with an LM386 amplifier stage, if more power is needed.
Also, that schematic does not look too reliable to me. If the component values are correct, then the two stages have a combined gain of 10000x, which is A LOT. And the op-amps are wired in a “positive feedback” configuration (output is fed-back to the +input), which is unlikely to produce the desired result.
It seems like this LM358 (operating as a differential op amp) is going into saturation or not operating at all because you have the matching Vcc or Vdd 10k impedance’s to both the positive rail and negative rail.
Take away R2 and it will actually be amplified. Not sure what the open loop feedback is but you can always trade R4 with a pot (potentiometer) to change the gain and experiment to get better results.
Great instructions! Thank you for sharing, I was trying to find a way to measure stereo sound from two microphones for a project and by reading this I got the big picture of how to do it.
hi this is a good experiment. here my experiment : i built a simple micro electret amplifier with 1 transistor c9014, 3 resistors and a capacitor. that give me a result :
silence –> amplitude around 100
loud knock –> amplitude around 997 (it’s the maxi)
i know an op amp is good for this kind of project but the results with a simpliest circuit is also fine for a clap switch application with an arduino.
Thanks for share.
Dimitar, nice article/tutorial, with lots of infos, thanks for the good information you are sharing…
I did a 1 transistor and also 2 transistor mic pre-amp but the LM358 is really nice option, very popular, easy to use and cheap device, and also can deal with 2 mics (dual op-amp capability) if needed (which in my case I think it makes a lot of sense)…
[Human Presence Science]
What I am thinking is to create a very simple device to detect human presence inside an environment (like a room), then use this information to control stuff like the intensity of illumination (light)…
My current plan is to use a LDR (light dependent resistor) with the LM358 sound detector as described in your project, combined them and start to collect some DATA in a “scientific” (as possible) fashion, so that the resulting device/knowledge can be put to use to control LED Light in a, intended, “intelligent” way…
First I want to collect as much DATA as possible, then, develop a body of knowledge around the human-presence subject, enough to start to play with the idea of having “intelligent light”…
The goal for the device is to be as simple and cheap as possible, so that it can be “incorporated” (embedded) into all kinds of products, not only lamps…
This “human presence detector” is part of a large thinking, to create things more “ECO” such as [desktop size] solar panels with rechargeable batteries, that can be used to provide illumination at night… and, the key for this thinking is POWER EFFICIENCY, so, first, I believe, we need to create some understanding around the subject and also a simple and cheap device to detect when there is human presence or not (inside an environment)…
So, what I can think for now is that we need 2 things:
a) Some data and thinking over the subject (of human presence)
b) A simple device to help detect human presence
The LDR + Mic-LM358 is a good starting point… perhaps 2 LDRs and 2 Mics (full use of the LM358 dual op-amp)…
Following are some pictures/diagrams I am creating around the subject…
[Human Presence Detector and Science]
“I often say that when you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meagre and unsatisfactory kind; it may be the beginning of knowledge, but you have scarcely in your thoughts advanced to the state of Science, whatever the matter may be.”
Lord Kelvin, 1883
The current “Neanderthal” lamps offers ON (100%) or OFF (0%), but perhaps there are others acceptable levels that may turn out to be practical and coherent…
I think that “ECO” is a good choice of word to use…
[A sustainable village as inspiration]
Also, a very inspirational village in Germany…
I will be doing experiments and sharing the results, hopefully, your little tutorial/project can grow to became a “universal sound detector module” for human presence detection…
Hi, I just want to share the initial setup/experiments/thinking…
I am experimenting with different values of resistors (picture)…
[Different values of resistors]
[Quiet (with little noise from outside)]
[Saying “hello”, 30cm from the top of the mic, 45 degrees]
[Knocking the table where the device is…]
[Higher Sensitivity, for noise detection]
Not sure about the results or even about the need of such possibility but perhaps we can get more sensibility (to detect small noise variation) by powering the amp with higher Voltage…
1) Power with 12V, [for example] (LM358 can work with ~32V…)
2) Shift the “silent” output level to around 2.5V (half the 1024 value for 5Volts ADC resolution), by changing the R2/R3 values (Voltage divider)…
3) Clipping the output using a Zener diode to limit it to 5 Volts…
Next picture illustrate the thinking…
[R2/R3 Voltage Divider?]
Did test changing R2/R3 “Voltage Divider Ratio”, at least for the noise-detection it seems to work… following pictures “test A” and “test B” shows the results…
[R2 = 100k, R3 = 100K]
[R2 = 100k, R3 = 33K]
Dimitar, I think your choice of the LM358 is a powerful solution, it ENCAPSULATES complexity in such a way that we can change input and output signals with relative simplicity, also the LM358 is very cheap and also very popular (easy to find) and considering that it is a dual-independent-amp channels, it can handle 2 microphones (makes sense for noise-detection) at the same time… everything in a compact 8 pin package…
For the moment, this CHIP (and the design) will be very helpful to investigated/experiment with the subject of human-presence-detection…
[About the last post…]
The “source” files here (made with Eagle Light Free version):
Modification 2 (12Volts?)
Hi, just want to say that after setting up the LM358-Mic device (as sound detector) and also starting to play with a LDR sensor (as light change detection) I am convinced that, because or their simplicity, these 2 devices are enough to “start” the thinking/experimenting about a “human presence science” (discipline)…
This thinking occurs to me a little while ago (1 or 2 years), back then I just did an entry in my notebook to try to investigate later, now I am convinced that such kind of device, to detect the presence of humans inside specific places (rooms, desks, etc) can be done, and can be done with simplicity and enough low cost to be useful to a wide range of subjects…
Of course, more sophisticated and complex devices already exist, but I am thinking about something BASIC and MODULAR, powered by flexible Open Source Code so that we can “embed” it into stuff very easy…
[The “Science” (Discipline) of Human Detection]
My current thinking is that, by having a good basic research around the subject, a basic body of knowledge will allow us to use SIMPLE DEVICES to fulfill basic tasks, and that it should be enough to more real life utility than our perception may have today…
If we leave 100% of the job to the hardware, then it is more likely to end up with complex, expensive state-of-art equipment, instead if we start to develop and use basic understanding about the human behavior inside environments, combined with a good range of experiments with light changes and sound inside such places, we may find that simple needs can be addressed with simple devices…
[The 80/20 Rule – Pareto Principle]
I am already taking notes of lots of things to consider/test, and just want to give 1 single example here: The 80/20 Rule (or Pareto Principle). It says that, as a rule (usually), when considering a room like an office, people (the users) will probably be, at least 80% of time, at some 20% of possible places… YES, this is not magic nor empty-guess… it is a way to use statistics/math to look at events, and we can use it, in our “science of human presence”…
Basically, the 80/20 Rule help us to focus the “detection” around 20% of the physical space, because this 20% of area will cover around 80% of the total time…
Well, still need to test this specific possibility (that is why we need these basic/cheap device, to test ideas like this one) but it show us that as our knowledge (about the subject) accumulates, there is the possibility to put less and less demand on the hardware side (devices), and this is my expectation…
[The Raspberry PI Zero Landmark…]
Of course, at some point, for some needs and users, the use of Linux OS and Open Software like “MOTION” (software to monitor video and detect changes) combined with a cheap webcam and a $5 RasPI Zero board will make a lot of sense, but even so, still, the choice of more simple devices will also give the users choice to cover all kinds of needs (think about battery life, for example)…
[Raspberry PI Zero picture]
The possibility to run full GNU, Linux and FOSS with a $5 boards is a kind of landmark, and it is ALSO a good idea for us to consider it as part of the “science of human presence (detection)”…
For me, MORE THAN EVER, a “study about human behavior/presence” can be very, very useful for all kinds of practical application…
The ability to run Java, Python, MySQL, Apache webserver with $5 is truly a PARADIGM CHANGE, and the good news is that we can take advantage of it to create/develop the Discipline/Study of Human Presence…
After initial data collection, I “reach” a set of values for components and will be using these values and the starting point to collecting data in more method way (“as scientific as possible”)…
The following 2 pictures are the actual diagrams/values that I am using at the moment (version v0.1 prototypes):
[lcdm – light change detection module “v0.1”]
[sdm – sound detection module “v0.1”]
[Arduino data sender]
[Python data receiver/record]
Tested only in GNU/Linux Debian/PC but I think it can run without problem on Raspberry/RaspBian (by connecting Arduino serial pins with RasPI GPIO serial pins)…
“A picture is worth 1000 words”, if so, lets advance 1000x the Science of Human Presence Detection… lol…
By modifying the Python script to read the serial, adding few lines, I am trying to create a simple VISUAL SCOPE, so that we can have a graphical display for the numbers coming from the serial interface…
The code still very small and buggy but it is enough to help us visualize the data…
Now, the script can record and show the data from the serial…
I will clean up and improve it with some basic features later, but if somebody is interested here are the current code (Duino sender-code and Python receiver-code)…
Hopefully it will be another little tool to help us to create this discipline (presence detection)…
Thank you for the post, I adapted it for the EL40X Berkeley edX robot project, I had to change the resistors tor the noniverting input bias so the output would lie between the maximum and minimum voltages (0 and 3.5 V). The photos helped a lot.
Reblogged this on amurchick and commented:
Усилитель на Lm358
Asking questions are actually pleasant thing if you are not understanding anything fully, except this article gives pleasant understanding even.
Who to make a 3v to 5v,step up boost power supply (USB Dc -Dc converter) draegram send me please.
Thank you very much for so clear post. Clicking on “Op Amp for Everyone” link it seems to be not solving correctly the URL given that it is a “https” nor “http”. So, just clicking on the link in your post leads you to http://www.ti.com/lit/an/slod006b/slod006b.pdf which is invalid address. The good one which leads you to the mentioned pdf is: https://focus.ti.com/lit/an/slod006b/slod006b.pdf
I’m currently doing a project to record mosquito sounds. Simply using a condenser microphone. I’m quite confuse which IC should i use. Either LM386 or LM358?
If you need to record the sounds with a higher audio quality, then the LM386 may be the better solution
Actually i’m going to record sound using some sort of microcontroller like arduino. So in that case also LM386 is better?
Actually i need best IC for microcontroller analog input. Assume reference voltage is 5V
instead of the circuit you have provided, i brought LM358 module as shown in link. could you please check and let me know how to use this properly ?
Is this a better module?
Hey Dimitar, great post. Thanks a lot!
Do you think the circuit could be modified to work with a 3v coin cell battery?
Yes, the LM358 can be powered with 3V and the circuit should work with no modifications. But keep in mind that the maximum output voltage is limited to “VCC – 1.5V”
Unfortunately it doesn’t work. Which is strange, because 3.3v from my Arduino output works perfectly.
Thats with the Arduino output, 3.3v:
And thats with a CR2032 coin cell, 3V:
Nevermind – I forgot to connect the negative pole from the battery to the Arduino ground. Works as you predicted!
How do you convert this circuit to a 2 terminal exit instead of 3?
I want it to be powered by the bias voltage of the mic input of the source which only accepts 2 inputs.
Do I simply connect my V_OUT_VC to VCC and then let my equipment correct the DC offset?
Hi Sir. I tried you design and it works for my school project m. Thank you. I just want to ask what is the formula for the input voltage Vin of your design? Given that you state the output voltage.
Pingback: Sound sampling with the Atmega32u4 breakout board+ « bobanaut
Pingback: Side Project – High Speed Photography trigger « Giant Pong – Making of.
Pingback: Basic Analog Circuits Exercise – Feb 26 | Kangmunicate Here
Pingback: Sound analysis in Arduino | Bocho's Blog
Pingback: Quanto rumore? : QUELog
Pingback: Controlling RGB LEDs with Music | jsimunic
Pingback: #9 | interruptserviceroutine