Difference between revisions of "BakeBit - Sound Sensor"

From FriendlyELEC WiKi
Jump to: navigation, search
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[BakeBit - Sound Sensor/zh|查看中文]]
 
[[BakeBit - Sound Sensor/zh|查看中文]]
  
==介绍==
+
==Introduction==
 
[[File:BakeBit - Sound Sensor.jpg|thumb|Sound Sensor]]
 
[[File:BakeBit - Sound Sensor.jpg|thumb|Sound Sensor]]
*BakeBit - Sound Sensor是一个声音检测模块,用于检测声音信号。模块使用了一个内置对声音敏感的电容式驻极体话筒检测声波信号,声波使话筒内的驻极体薄膜振动,导致电容的变化,而产生与之对应变化的微小电压,经过LM358放大后输出。
+
* 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.
  
==特性==
+
==Hardware Spec==
* 使用标准的2.0mm 4 Pin BakeBit接口
+
* Standard 2.0mm 4-Pin BakeBit Interface
 
[[File:BakeBit - Sound Sensor_PCB.png | frameless|320px|BakeBit - Sound Sensor]]
 
[[File:BakeBit - Sound Sensor_PCB.png | frameless|320px|BakeBit - Sound Sensor]]
  
* 引脚说明:
+
* Pin Description:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
|名称 || 描述
+
|Pin || Description
 
|-
 
|-
|GND  ||
+
|GND  || Ground
 
|-
 
|-
|5V    || 电源5V
+
|5V    || 5V Supply Voltage
 
|-
 
|-
|NC    ||
+
|NC    || Not Connected
 
|-
 
|-
|SIG  || 信号
+
|SIG  || Signal
 
|}
 
|}
== 示例程序:Sound Sensor ==
 
  
这个示例用Sound Sensor实现一个声控开关,当检测到环境声音达到指定的分贝时,点亮LED。
+
== Code Sample:Sound Sensor ==
  
=== 硬件连接 ===
+
When this program runs if surrounding environment’s sounds reach a threshold value the LED will be turned on.
简单的将 Sound Sensor 模块插入 A0 接口,将 LED 插入 D5 接口,如下面这样:
+
 
 +
=== Hardware Setup ===
 +
Connect the Sound Sensor module to the NanoHat Hub's A0 and the LED module to the NanoHat Hub's D5:
  
 
::{| class="wikitable"
 
::{| class="wikitable"
Line 36: Line 37:
 
|}
 
|}
  
=== 示例源代码 ===
+
=== Source Code ===
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
Line 77: Line 78:
  
  
=== 运行示例 ===
+
=== Run Code Sample ===
 
   
 
   
假设你已经参考[http://wiki.friendlyarm.com/bakebit bakebit教程]安装了BakeBit源代码,<br />
+
Before you run the code sample you need to follow the steps in [http://wiki.friendlyarm.com/bakebit bakebit tutorial] to install the BakeBit package.<br />
要运行示例程序,可以在开发板上进入 BakeBit/Software/Python目录,运行bakebit_sound_sensor.py:
+
Enter the "BakeBit/Software/Python" directory and run the "bakebit_sound_sensor.py" program:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
cd ~/BakeBit/Software/Python
 
cd ~/BakeBit/Software/Python
Line 86: Line 87:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== 运行结果 ===
+
=== Observation ===
  
对着声音传感器制造点声音,例如拍打手掌,LED将被亮起。
+
When you make some sounds to the sound sensor and if the sounds are big enough the LED will be turned on.
  
==相关资料==
+
==Resources==
 
*[Schematic]([http://wiki.friendlyarm.com/wiki/images/f/ff/02-SCHEMATIC_Sound_Sensor.pdf BakeBit - Sound Sensor.pdf])
 
*[Schematic]([http://wiki.friendlyarm.com/wiki/images/f/ff/02-SCHEMATIC_Sound_Sensor.pdf BakeBit - Sound Sensor.pdf])
*[BakeBit Github项目](https://github.com/friendlyarm/BakeBit)
+
*[BakeBit Github Project Page](https://github.com/friendlyarm/BakeBit)
*[BakeBit Starter Kit手册](http://wiki.friendlyarm.com/bakebit/bakebit_starter_kit_manual_cn.pdf)
+
*[BakeBit Starter Kit User's Manual](http://wiki.friendlyarm.com/bakebit/bakebit_starter_kit_manual_en.pdf)
 +
 
 +
==Update Log==
 +
===December-14-2016===
 +
* Released English version
 +
 
 +
===Jan-19-2017===
 +
* Renamed "NEO-Hub" to "NanoHat-Hub"
 +
 
 +
===Jan-20-2017===
 +
* Renamed "NanoHat-Hub" to "NanoHat Hub"

Latest revision as of 08:21, 20 January 2017

查看中文

1 Introduction

Sound Sensor
  • 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

BakeBit - Sound Sensor

  • 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 Setup

Connect the Sound Sensor module to the NanoHat Hub's A0 and the LED module to the NanoHat Hub's D5:

Sound Sensor-1.jpg Sound Sensor-2.jpg

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")

Github


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

5 Update Log

5.1 December-14-2016

  • Released English version

5.2 Jan-19-2017

  • Renamed "NEO-Hub" to "NanoHat-Hub"

5.3 Jan-20-2017

  • Renamed "NanoHat-Hub" to "NanoHat Hub"