Monday, February 17, 2014

High Sensitivity Arduino Sound Level Detector

Generally we want to sense the environment when something interesting is occurring. Sometimes the presence of sound is indicative of an interesting activity. If we can detect sound level we can trigger a sensing activity to capture information about the activity of interest. I have posted a short video of this simple high sensitivity Arduino sound level detector working.

In this project we use an Arduino Uno, an electret microphone and an LM358 dual operational amplifier to create a simple sound level detector. The signal from the mic is amplified by the one side of the LM358 with a gain of approximately 221 (see op-amp wiki) as defined by the 220k feedback resistor and the 1k pull down resistor connected to the negative input of the LM258 amplifier. The output of the first stage amplifier provides input to the other side of the LM358 used as a comparator. The triggering threshold of the comparator is controlled using the potentiometer. When the audio signal from the first amp exceeds the triggering threshold the comparator sends a digital '1' to the Arduino Uno on pin 8. When the Uno detects the sound level high input it turns an LED on. You can see a schematic diagram of the sound detection part of the circuit below.

Prototyping this on a breadboard looks something like this:

The actual breadboard prototype appears below:

... and the simple sketch I used to drive the Arduino Uno appears below:

I include the sketch code below if you'd like to try it out yourself:

#define SOUND_DETECTED_DIGITAL_IN_PIN 8
#define LED_DIGITAL_OUT_PIN 7

void setup(){
  pinMode(SOUND_DETECTED_DIGITAL_IN_PIN, INPUT);
  pinMode(LED_DIGITAL_OUT_PIN, OUTPUT);
}

void loop(){
  if(digitalRead(SOUND_DETECTED_DIGITAL_IN_PIN) == HIGH){
    digitalWrite(LED_DIGITAL_OUT_PIN, HIGH);
    delay(50); // delay long enough for you to see the LED on
  }
  else {
    digitalWrite(LED_DIGITAL_OUT_PIN, LOW);
  }
}

Stay tuned for projects that receive the sound detection as input and use it to drive other interesting activities. Have fun. Feel free to share below if you built something cool with this, or have some ideas for enhancements.

You may also be interested in a high sensitivity vibration sensor using the Arduino Uno.

Note: if you notice your output locking in on state try lowering the feedback resistor of the op-amp from 220k to something lower, for example 160k.

If you are interested in how this type of sensor can be integrated into a broader solution that includes notification of detected sound level on a users Android phone see Detect Intrusion with Passive Infrared, Sound, or Vibration

17 comments:

  1. Hello,

    Do you know the sensitivity of your sound level/microphone? I am trying to build an SPL monitor with a sensitivity of at least 1dB.

    Thanks!

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Hi Victoria, I haven't measured. However with this circuit in all applications I have done the highest sensitivity is too sensitive and needs to be reduced. Have fun.

      Delete
  2. I am looking to use something similar to your design in an industrial setting. there will a constant noise level and i am wanting to monitor excessive noise levels e.g a machine takes a knock. Would varying the potentiometer be able to account for the standard noise level?

    ReplyDelete
  3. Possibly. It would depend on the contrast between the ambient noise and the excessive noise levels you expect. In other words, there should be no problem adjusting the potentiometer so it doesn't trigger on regular ambient noise. The question is whether the interesting events you want to alert on are significantly louder to where they would trigger above this threshold. I recommend a quick prototype and test in the target environment.

    ReplyDelete
  4. So many inportant information are available here also have some interesting things. Looking forward to find more topic.
    Level Sensor

    ReplyDelete
  5. Hi,

    I have a project involving triangulation by tdoa of sound which requires use of 3 equaly calibrated microphones. I have used the sparkfun sound sensor board
    https://www.sparkfun.com/products/12642, but have found that they are firstly overpriced and difficult to calibrate. By replacing R17 with a trimpot, i came quite close to same calibration for 3 boards hooked up to a Teensy 3.5 Digital Inputs 10,11 and 12.

    I require a circuit which firstly has an opamp (LM358), bandpass filter 300hz-3Khz and an adjustable trimpot for gain and calibration. Output Digital High/Low signal to the Teensy 3.5 for use with interrupts.

    I have built the circuit as you have designed and found that it is easy to build and fits the specification above except for the bandpass filter. Would you be so kind as to guide me in the right direction in adding a bandpassfilter?

    ReplyDelete
  6. Siementransmitter is provider/exporter Ultrasonic Level Transmitter of Wastewater and common water associations perceive how basic lift stations are in urban concentrations in Florida. Upkeep and investigating them all the time is fundamental for any gathering.see more:-www.siemenstransmitter.com

    ReplyDelete
  7. Hi. By using ur project, is it possible to display the decibel value of the sound in an LCD, then a beep will occhr when the sound passes the threshold value?

    ReplyDelete
    Replies
    1. I am looking for an answer to the same question, did you come up to an answer to it?

      Delete
  8. I'm creating a project to listen to mechanical watches and their beat and I decided to test this setup.
    I've tried the shelf sound detection modules before but it seems they we're not sensitive enough. They are using pretty much the same components as you have but it's so much more fun to setup it yourself and learn something from it.
    I got your solution working however, unfortunately, it too had problems with the sensitivity. I guess that a electret microphone is not suitable for my project and I need something else? Any suggestions or guides?

    Thanks!

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. informative content keep blogging like these with new concept

    ReplyDelete
  11. We offer various type of level sensor which are used in order to track the level of fluids or gases in a particular tank system. Whether you are going to go for monitoring any liquid, the sensor is a mandatory part which is included in all metric devices. This is actually the component which is going to be detecting the level of any chemical and providing you the data. With this in mind, there are quite a few different types of Telemetry Chemical Level Sensor and yet these sensors are among the most popular ones. For more details visit iconprocon.com

    ReplyDelete