Cheap Sound Sensor for AVR

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
  • 2 capacitors 0.1u
  • electret microphone

Prototyping the amplifier

Putting things together on a breadboard.

IMGP1255

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.
IMGP1253

The schematic for rebuilding.
mic-schematic

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

Video

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


Click To Play

Conclusion

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.

Links

Del.icio.us Del.icio.us Digg! Digg

 

25 Responses to “Cheap Sound Sensor for AVR”

  1. Alan Says:

    Nice job, it seems to follow the music quite well!

  2. Philippe Says:

    30 years ago I built something like that… it was all analog and involved lighting a 115v bulb.
    Funny thing is that it probably cost more to build at the time.

  3. Justin Says:

    Thank you so much for the link to the schematic for the mic and LED, I have made a 4X4X4 RGB LED cube that is going to go to sound but I had no way to read it, I just got the parts and it works great. I have to code the LEDs though. Thanks a lot,
    Justin

  4. alaa Says:

    I need small sound sensor can sense high noise, working by battery, working in open area(high limitation). the output of this sensor is a sound also as handset or small speaker without display screen or indication lamp.
    for example: i use hanset in my ears to say to me how the noise level is.

  5. odiernod Says:

    I put this circuit together too and am happy to say that it works just fine, however, “how” does it work? What is the capacitor for? Why is there a resistor in parallel with the base and collector of the transistor? I am used to using transistors in switching applications, however I am interested in why this circuit can do what it does.

  6. Alex Says:

    Hi odiernod,
    cool that it worked for you!
    The capacitor is used to decouple the mic from the transistor. It is used to transmit only the changes in voltage. I am quite sure that the resistor is used to adjust the amplification, but my knowledge in analog circuits is quite limited.

    You can also take a look at
    http://tinkerlog.com/2007/10/22/diy-tengu-on-a-breadboard/ for a more integrated amplifier.
    Cheers,
    Alex

  7. odiernod Says:

    I made a colorful lamp out of my sound sensor circuit. No singing faces or anything, but it still looks cool. I’ll post a vid sometime next week or so.

    Dom

  8. Azda Says:

    hi, i am interested in building this for a school project and i am wondering if this simple circuit will work as it is on its own?

  9. Alex Says:

    Hi Azda,
    what do you mean by “work as it is on its own”?
    It can be powered by batteries, then it will work on its own.
    If you mean, if it could work without the microcontroller, yes, I think it would work. You have to attach another transistor to the collector of the first one and use it as a switch to control the LED. I haven’t tested that, but it could work.
    Cheers,
    Alex

  10. Azda Says:

    thanks for the help alex

  11. Azda Says:

    would a MIC1 work with this circuit, and could you possibly post/send images of this circuit bread boared on its own- as on the top image without the microcontroller using a battery.

  12. Michael H Says:

    Alex,
    I know this is a little off topic, but I’m not finding answers elsewhere. Can you help me figure out how I could use a setup like this with a 12V neon car light? (4 ft, and I think probably 2.5 amps?) I know this is possible, I just am unsure of what to change.

    Thanks for the off topic help.

  13. Alex Says:

    Hi Michael,
    hmm, not sure about a 12V setup. You will need really powerful transistor to switch 2.5 amps at 12V. I am not into analog electronics, more microcontrollers. But I am sure you wont need the microcontroller for your purpose.
    Cheers,
    Alex

  14. karim Says:

    is this circuit can be used to detect alarms without any false indications

  15. Alex Says:

    Hi karim,
    yes, I think it can be used as sensor for an alarm.
    Without any false indications? That depends on your environment.
    Cheers,
    Alex

  16. karim Says:

    Thank you very much

    i’m really amazed of your fast response

  17. BIGBUG Says:

    THANK YOU! This little circuit, with a few minor changes, is just what I was looking for to add bidirectional hearing to my oobug robot. Was looking for something for weeks.

    Ted
    Savage Innovations
    www.oobug.com

  18. Alex Says:

    Ted, great to hear that. I am waiting to see the final result.

  19. BIGBUG Says:

    Alex,

    Could you share the part number for the electret you used in this project?

    Have you done any experimenting with the sensitivity of the circuit?

    Ted

  20. Alex Says:

    Ted,

    here is the link for the mic http://www.reichelt.de/?;ACTION=3;LA=4;GROUP=IA2;GROUPID=3604;ARTICLE=11357;
    The id is “MCE 100″.

    No, I haven’t done anything with the sensitivity.

    Cheers,
    Alex

  21. Reece Says:

    Wait a minute…In the instructions it says ‘electret microphone’, but in the schematics there are only TWO connections to the microphone shown. Is it an electret or a condenser mic? I’m confused…

  22. Alex Says:

    Hi Reece,
    following Wikipedia http://en.wikipedia.org/wiki/Electret_microphone it is an electret microphone which is a subtype of a condenser microphone. The one that I used has only two connections.
    Cheers,
    Alex

  23. Reece Says:

    Ok. So I THINK I found the right microphone element in my box of goodies (old circuit boards from random stuff). I got it from an old cordless phone. I built the circuit for a project I’m doing. I haven’t tested it yet, though…

    Here is a pic of the completed circuit:

    http://www.flickr.com/photos/7507189@N04/2612530416/

  24. Reece Says:

    Yup. It works great. The butter zone trigger value is ~150 from the ADC. Great circuit; it’s so simple and I didn’t even need to make a complex op-amp one with all those capacitors and resistors. Great for a simple electronic ‘ear’ that can recognize simple handclaps. Thanks for the simple design!

  25. Alex Says:

    Great to hear that it works.
    Kudos for the design goes to Andrew, who posted the design on Reconn’s world.
    http://www.reconnsworld.com/forum/read.php?9,10

Leave a Reply