Cheap Sound Sensor for AVR

Posted by on May 20, 2007 in avr, sensor, sound | 68 Comments

I searched the web for a cheap method to let the ATmega respond to sound. My knowledge in analog circuits is very limited, but what I do remember, is that you can not attach a electret mircophone to a controller pin. The signal of the microphone is just too small and has to be amplified. There is much of information out there, especially on diy amplifiers. I stumbled upon this little circuit here. It consists only of a handful of components:

  • 2 resistors 10k
  • 1 resistor 100k
  • transistor 2N3904
  • 1 capacitor 0.1u
  • electret microphone

Prototyping the amplifier

Putting things together on a breadboard.


Actually I had no 2N3904 around, so I replaced it with a BC337. The circuit is a emitter circuit with voltage degeneration (I dont know if that exists in english). I dropped the couple capacitor and took the signal right away at the collector.

Prototyping with the ATmega

The sound sensing is done with the ADC of the ATmega. A simple program reads the analog value of the amplifier over and over. If the value (loudness) exeeds a specific level, an LED is lit.

The schematic for rebuilding.

The code can be found here mic_sensor.c. It is just hacked together and has lots of room for improvements.


Here is a video that I made. Has lousy quality, for both, video and audio.

Click To Play


It was easy and worked pretty well. I enjoyed looking at the LED responding to the music. I haven’t recorded anything with this amplifier, it might sound awfull. Next steps could be playing the sound back or be able to analyze the sound (FFT). And (re-)learning more on analog circuit design.



  1. Amitabh
    13. April 2011

    Hello all, Interesting post.
    Hereis what I am looking for. Did analog circuit design 25 years ago. Looking for up to date methods:

    I have an Alpine card CD receiver that has an Interrupt lead. I would like to take an iPod headphone out and generate a trigger from a circuit every time there is audio on the headphone jack. the trigger signal wil be connected to the interrupt lead on the head unit. I also need to hold the lead high for say 1-4 seconds once the headphone out goes higher than a preset value.

    How do I do this?

    Thanks in anticipation. Cheers. -Amitabh

  2. Pieter
    21. April 2011

    Hello Alex,

    Great tutorial, very well explained! I tried to recreate the setup, but it doesn’t work very well. It only responds when I blow into the speaker.

    I used exact the components you described at the beginning, including the 2N3904.

    One difference, but I don’t know if it matters: my electret is connected via two cables of about 20 cm. Could this influence the gain? Any other idea why my preamp performs so badly?


  3. Alex
    30. April 2011

    Hi Pieter,
    the gain of the original circuit is really really small. Try to log the values you get while it’s silent. Then log the values while you are blowing or playing loud music. Maybe that can help.
    Otherwise you may want to choose another circuit with more gain.

  4. NOOR
    21. May 2011

    just a simple question the output should be analog or a trigger ?!

  5. Alex
    21. May 2011

    The output is analog but I needed only a trigger.

  6. Vignesh
    19. August 2011

    Hey, great tutorial! I’m thinking of recreating it, though not exactly the same.. Could you tell me if you really need capacitors C2 and C3 which are connected to ports 9 and 10 on the schematic above? Also, is Q1 needed? I’m thinking of using making the following circuit, connecting the “Output to next stage” to an ADC pin, and a servo to an output pin.

    Thanks for your time,
    Vignesh R.

  7. Raj
    29. August 2011

    I have no knowledge in microcontrollers but i can work with labview. I am searching for sound sensor that hear the noise from a pump. Do you have any idea to do this. I had a pump that can give noise when inside the storke is touched to mechanical parts. I need to adjust it by using sound sensor. Can you help with any idea,

  8. anzal
    9. December 2011

    yaa i have no idea about sound sensor.may i know how much money should i have to spend for this projet??

  9. Alex
    24. December 2011

    It’s only a couple of bucks. Only cents if you don’t count the microcontroller.

  10. Moritz
    15. January 2012

    thank you for this great setup. We built a RGB-LED Controller in a project and I added the Sound Sensor. We used only SMDs, so I choose the MMBT3904 instead of the 2N3904. Well, it does work. But I have the same problem as Josh(#38). My ADC output value is allways around 800 (10bit). And it only varies about +/- 10 when I play some sounds, so it is very tricky to find the right trigger level. What is your difference between silence and sound? I used an MCE101 instead of the MCE 100 but the only difference should be the cable… Has anyone an idea what could cause my high level?

  11. Moritz
    15. January 2012

    Sorry for the double post.
    It works just fine with a value of 800 now!
    My problem was, that I sent every single value to my console with printf and therefore the programm was to slow. Now it is really sensitiv, even to the sound of me writing on my keyboard!
    Again thank you for this real simple but great sound sensor!

  12. saqib
    30. January 2012

    hey, i was jus wondering if i can put the output from the amplifier into an arduino uno?

  13. Krzysiek
    30. January 2012

    The diffrence between adc output is probably caused by AVREF specification. In atmega88 u can choose between AVcc/1.1V/AREF . I calculated aprox values with diffrent VRefs and thats what i got:

    for AVcc ~ 176
    for 1.1V ~ 800

    the formula is very simple ADC = AIN/AVREF * 1024

    PS. I used BC337 and output voltage was 0,86V.
    PS2. Nice and simple amp :)

  14. Cory
    16. February 2012

    In the tutorial, you say you used 2 capacitors at 0.1uF but, i only see one in your design and schematics. Where is the second one located (if there is a second)?

  15. Alex
    16. February 2012

    You’re right, it’s only one.

  16. Designing Simple Sound Sensor Circuit Diagram | Circuit diagram wiring
    19. March 2012

    [...] following page outlines detail description and explanation on how to design a Simple Sound Sensor Circuit Diagram [...]

  17. Luu
    27. March 2012

    Hi Alex,I measured the output of the BJT used VOM and found it to stand still in a position (with sound-needle run).
    The sound sensor true or false? I don’t connect with AVR,i just test by voltage-VOM!
    PL help me,thank for your watching my question!

  18. Alex
    30. March 2012

    Hi Luu,
    you probably can’t see changes on a voltmeter because it’s too slow and the changes are too small.