BakeBit - Sound Sensor
From FriendlyELEC WiKi
Contents
1 Introduction
- The BakeBit - Sound Sensor is a sound detection module. The module contains an electret condenser microphone. Sound waves impinging on the diaphragm cause the capacitance between it and the back plate to change synchronously, this in turn induces an AC voltage on the back plate, which is amplified with LM358 as output.
- Its default output is high. When it detects a sound wave it will output low. When no sounds are detected it will output high.
2 Hardware Spec
- Standard 2.0mm 4-Pin BakeBit Interface
- Pin Description:
Pin | Description |
GND | Ground |
5V | 5V Supply Voltage |
NC | Not Connected |
SIG | Signal |
3 Code Sample:Sound Sensor
When this program runs if surrounding environment’s sounds reach a threshold value the LED will be turned on.
3.1 Hardware Connection
Connect the Sound Sensor module to the NEO-Hub at A0 and the LED module to the NEO-Hub at D5:
3.2 Source Code
import time import bakebit # Connect the BakeBit Sound Sensor to analog port A0 # SIG,NC,VCC,GND sound_sensor = 0 # Connect the BakeBit LED to digital port D5 # SIG,NC,VCC,GND led = 5 bakebit.pinMode(sound_sensor,"INPUT") bakebit.pinMode(led,"OUTPUT") # 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 = bakebit.analogRead(sound_sensor) # If loud, illuminate LED, otherwise dim if sensor_value > threshold_value: bakebit.digitalWrite(led,1) else: bakebit.digitalWrite(led,0) print("sensor_value = %d" %sensor_value) time.sleep(.2) except IOError: print ("Error")
3.3 Run Code Sample
Before you run the code sample you need to follow the steps in bakebit tutorial to install the BakeBit package.
Enter the "BakeBit/Software/Python" directory and run the "bakebit_sound_sensor.py" program:
cd ~/BakeBit/Software/Python sudo python bakebit_sound_sensor.py
3.4 Observation
When you make some sounds to the sound sensor and if the sounds are big enough the LED will be turned on.
4 Resources
- [Schematic](BakeBit - Sound Sensor.pdf)
- [BakeBit Github Project Page](https://github.com/friendlyarm/BakeBit)
- [BakeBit Starter Kit User's Manual](http://wiki.friendlyarm.com/bakebit/bakebit_starter_kit_manual_en.pdf)
5 Update Log
5.1 December-14-2016
- Released English version