Sound detector

I have been so busy at work that I couldn’t update this blog for some time. I can’t believe it’s already October!

A few days ago, I was looking for something in my junk (but goodies) drawers in the basement, where my small working table is, when I saw a few different sizes of condenser microphones (aka electret) which I don’t even remember where I took them from. Probably from old computer’s microphones or cellphones.

Anyway, I got an idea to make something fun with them. You may have heard or seen the commercial of a clapping light switch. I thought I could make it easily and use it for many other applications such as night security system or sound activation switches or something like that. So I started looking for parts again from my junk drawers.  First thing came to my mind was simple one transistor amp like the one below I found from google image search. If you search keywords like “mic amplifier circuit,” you will find similar ones easily.


I remember I have built one like this long time ago but I don’t recall whether it worked properly or not. Anyway I built one quickly on a bread board and tested the output using an earphone. Well, it was not good enough to trigger any circuit.  So I added another stage of the amplifier.  With this addition, the effect was clear and amazing.  I could even hear rustling of my sleeves and keyboard typing loudly. Now I removed the earphone and connected the output to the analog pin 5 of JeonLab mini v1.3 and read the signal. The result was not as good as I expected. It was very noisy and there was no difference between the background level and any sound like clapping. There are a few reasons I could think about. It could be the poor quality power source from USB (since I needed to use FTDI to read the numeric values, the power for the mic amp, JeonLab mini, and the FTDI board were all connected to the USB. Another reason might be frequency range of the mic. If it is so wide and pick up all the low and high frequency noise that human can not hear, that would mess up signal reading. In that case, I would need a band pass filter. One more thing I could think of was the different impedance between the earphone and the ATmega328 chip analog input pin.  Anyway, I have tested all the possibilities mentioned above and found it was combined case.  Finally, I connected two supercap (2.7V, 10F each) which is one of my favorite power source and added two resistors and a capacitor as a low pass filter as shown below.

DSCN5731

DSCN5733

DSCN5729

The result was very satisfactory. It could be activated well enough for any sound (e.g. talking or any sound around us) and lit the LED(#13).

Here is the Arduino code.  It’s very simple program that reads analog pin 5 and if it exceeds certain level turn the LED #13 on.  As for the threshold (5 in this case), you need to find a proper number by trial and error. This value may be different for your set-up depending on the type of microphone or band pass filter you want to use.


/*
 Sound detector: LED
 Created: Sep 27, 2011
 Modified: Oct 3, 2011
 by Jinseok Jeon
 https://jeonlab.wordpress.com
 */

#define micPin 5

void setup() {
  pinMode(13, OUTPUT);
}

void loop() {
  if (analogRead(micPin) > 5) { //try 5-50
    digitalWrite(13, HIGH);
    delay(1);
    digitalWrite(13, LOW);
  }
}

The circuit diagram is as below.
Sound detector circuit

There are two stages of 2N3904 (npn transistor) based simple amplifier and noise filter at the output of the amplifier before it is send to the JeonLab mini analog pin 5. You may find the sensitivity might be different from mine if you use different type of microphone.  If that’s the case, I would suggest to do some experiment with those values of the filter circuit (C4, R7 and R6).  I have tested with a few different sizes and models of the microphone and found all of them worked fine with the circuit above. As shown in the above picture, I used a 100 ohms trimmpot for the R7, but you can use any value between 10 and 100 ohms. There are no big difference with this resistance.

As a tip to monitor the signal coming in through the analog pin 5, I used the Poorman’s oscilloscope and it worked really well.

Advertisements
About

Opto-mechatronic Engineering scientist.

Posted in Electronics, JeonLab mini

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

October 2011
S M T W T F S
« Jul   Nov »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
Archives

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 11 other followers

%d bloggers like this: