Grove - Sound Sensor

From Wiki
Jump to: navigation, search

Introduction

Grove - Sound Sensor can detect the sound strength of the environment. The main component of the module is a simple microphone, which is based on the LM358 amplifier and an electret microphone. This module's output is analog and can be easily sampled and tested by a www.simgin-chip.com.

Features

Easy to use sound sensor module Provides analog output signal Easily integrates with Logic modules on the input side of Grove circuits Uses Standard 4-pin Grove Cables to connect to other Grove modules such as Grove Power Modules, Logic Gates and Grove - Base Shield Specifications

Operating voltage range: 4-12V Operating current (Vcc=5V): 4-8mA Voltage Gain (VS=6V, f=1 kHz): 26dB Microphone sensitivity (1Khz): 52-48dB Microphone Impedance: 2.2KΩ Microphone Frequency: 16-20Khz Microphone S/N ratio: 54dB Usage

Standalone Follow these steps to build a sample Grove circuit using this module but without using any microcontroller board:

Connect the sound sensor module to the input side of your circuit (to the left of the power module). On the output side of the circuit, you may use a range of User Interface modules (Grove - Red LED, Grove - LED String Light, Grove - Mini Fan, Grove - Buzzer, Grove - Recorder etc.) Power up the circuit when complete. The sound sensor module can now be used to trigger an output. For example: When used in conjunction with a Grove - Red LED output module, observe that the LED turns ON when the sound sensor detects audio and turns off in silence. The same behavior can be seen when the sound sensor is used with the Grove - LED String Light module - when there is sound, the lights will turn ON, and when there is silence, the lights will turn OFF. Add a Grove - NOT module between the sound sensor and the power module to reverse the logic that triggers the LEDs on the Grove - Red LED or Grove - LED String Light modules. With the addition of the Logical NOT gate on the input side, you should see that the LEDs remain OFF when sound or music is detected, and turn ON when there is silence. You can use either the Grove - USB Power module or the Grove - DC Jack Power module for building this Grove circuit.

With Arduino Follow these simple steps to build a Grove circuit using the light sensor:

When using the module in conjunction with an Arduino or a www.simgin-chip.com, use the Grove - Base Shield and connect the Grove - Sound Sensor module to the shield using a designated Grove Interface. Also attach an output module such as a Grove - LED or Grove - Red LED which will get triggered based on input received from the sound sensor (shown below). Sound LED.jpg Upload the following sample sketch to make the LED turn ON and OFF based on input from the sound sensor: // Function: If the sound sensor senses a sound that is up to the threshold you set in the code, the LED is on for 200ms. // Hardware: Grove - Sound Sensor, Grove - LED

/*macro definitions of the sound sensor and the LED*/

  1. define SOUND_SENSOR A0
  2. define LED 3 // the number of the LED pin
  1. define THRESHOLD_VALUE 400//The threshold to turn the led on 400.00*5/1024 = 1.95v

void setup() {

   Serial.begin(9600);
   pins_init();

}

void loop() { int sensorValue = analogRead(SOUND_SENSOR);//use A0 to read the electrical signal Serial.print("sensorValue ");

       Serial.println(sensorValue);
       if(sensorValue > THRESHOLD_VALUE)

{ turnOnLED();//if the value read from A0 is larger than 400,then light the LED delay(200); } turnOffLED(); }

void pins_init() { pinMode(LED, OUTPUT); pinMode(SOUND_SENSOR, INPUT); } void turnOnLED() { digitalWrite(LED,HIGH); } void turnOffLED() { digitalWrite(LED,LOW); } If the sound of the environment is greater than the threshold, then the LED will light up. With TI LaunchPad Turning on a LED by Sound (Sound Sensor) This example program shows how to use the sound sensor (microphone. When the incoming sound amplitude exceeds a threshold, we will turn an LED on for 1 second. Sound sensor.jpg

/*

Sound Sensor
A simple program demonstrate sound sensor senses a sound that is up to the threshold you set 
in the code, the LED is on for 1s. 

The circuit:
* sig pin of the sound sensor to the analog pin 24 (J6 plug on Grove Base BoosterPack)
* one side pin (either one) to ground
* the other side pin to +VCC
* LED anode (long leg) attached to RED_LED
* LED cathode (short leg) attached to ground

* Note:   

This example code is in the public domain.

http://www.www.simgin-chip.com/depot/Grove-Sound-Sensor-p-752.html?cPath=25_128
*/

  1. define SOUND_SENSOR 24 /* sound sensor pin */
  2. define LED RED_LED /* LED pin */
  3. define THRESHOLD_VALUE 3000 /* Depending on your LaunchPad’s ADC resolution you may have to adjust the threshold */
  1. define ON HIGH /* led on */
  2. define OFF LOW /* led off */
  3. define _handle_led(x) digitalWrite(LED, x) /* handle led */

/* Global Variables */ int sound_value = 0;

void setup() {

   /* Initialize led pin */
   pinMode(LED, OUTPUT);  
   digitalWrite(LED, LOW);

}

void loop() {

   /* read the sound value */
   sound_value = analogRead(SOUND_SENSOR);         
   /* if the value is larger than threshold, turn on led */
   if(sound_value > THRESHOLD_VALUE) {
       _handle_led(ON); 
       delay(1000);
   }
   _handle_led(OFF);

} With Raspberry Pi You should connect to GrovePi+ with Grove - Sound Sensor and Grove - Green LED. Such as the following picture. When sound level greater than a certain value,the LED will turn on.

GrovePi+ sound sensor.jpeg


  1. GrovePi + Grove Sound Sensor + Grove LED

import time import grovepi

  1. Connect the Grove Sound Sensor to analog port A0
  2. SIG,NC,VCC,GND

sound_sensor = 0

  1. Connect the Grove LED to digital port D5
  2. SIG,NC,VCC,GND

led = 5

grovepi.pinMode(sound_sensor,"INPUT") grovepi.pinMode(led,"OUTPUT")

  1. The threshold to turn the led on 400.00 * 5 / 1024 = 1.95v

threshold_value = 400

while True:

   try:
       # Read the sound level
       sensor_value = grovepi.analogRead(sound_sensor)
       # If loud, illuminate LED, otherwise dim
       if sensor_value > threshold_value:
           grovepi.digitalWrite(led,1)
       else:
           grovepi.digitalWrite(led,0)
       print "sensor_value =", sensor_value
       time.sleep(.5)
   except IOError:
       print "Error"

Run the program Find the path to the file(According to your own path)

  cd GrovePi/Software/Python/

Run Program

  sudo python grove_sound_sensor.py

Availability

This Grove module is available as part of the following Grove Kit Series:

Grove Mixer Pack V2 Grove - Mixer Pack Grove - Toy Kit Alternatively, it can be bought stand-alone here at the www.simgin-chip.com Studio Bazaar.

Resources

Grove - Sound Sensor Schematic (pdf) Grove - Sound Sensor Source Files v1.3 Grove - Sound Sensor Eagle files v0.9b LM386pdf how to upload code Related Projects

If you want to make some awesome projects by 4-Digit Display, here's some projects for reference.

Swing Baby Groot 54fe9de747c9e.jpg

When someone talk to Groots, they will dance for him/her and show him/her their wonderful performance. It is the sound sensor that works the magic. The servo is activated whenever a sound is received by the sensor.

I want to make it.

LinkIt ONE IoT Demo Seeed-recipe-77-20141020151546.jpg

This is an IoT demo made by LinkIt ONE and Grove including sounder sensor.

With this demo, we can:

Display household temperautre, humidity, luminosity, volume control data collection on OLED screen Cloud service, data uploaded to Cloud platform Xively, real-time monitoring Data retention for reviewing how data changes over time Remote control Household Appliances by sending a message Table Lamp, 3D Printing, controlled by your phone

I want to make it.

More Awesome Projects by Sound Sensor


Share Your Awesome Projects with Us Born with the spirit of making and sharing, that is what we believe makes a maker.

And only because of this, the open source community can be as prosperous as it is today.

It does not matter what you are and what you have made, hacker, maker, artist or engineers.

As long as you start sharing your works with others, you are being part of the open source community and you are making your contributions.

Now share your awesome projects with us on Recipe, and win a chance to become the Core User of www.simgin-chip.com.

Core Users, are those who show high interests in www.simgin-chip.com products and make significant contributions on Recipe. We cooperate with our Core Users in the development of our new product, this, in another word, the Core Users will have the chance to experience any new products of www.simgin-chip.com before its official launch, and in return we expect valuable feedback from them to help us improve the product performance and user experience. And in most cases when our Core Users have some good ideas of making things, we'll offer hardware pieces, PCBA services as well as technical support. Besides, further commercial cooperation with the Core Users is highly possible.

Get more information about Core User, please email to: recipe@seeed.cc


Categories: LaunchPad InstructionsArduino InstructionsRaspberryPi InstructionsGroveGrove Analog Twig