dvaosta
Posts: 2
Joined: Mon Oct 30, 2017 9:44 am

Efficient sound activated recording

Mon Oct 30, 2017 9:55 am

Hi,
for my thesis I need to use raspberry pi to capture sounds and analize them. To improve efficiency, I'm looking for an efficient way (a busy cicle is not an option) to start recording only when there is a noise loud enough.
So what I ask you is if it's possible to get an interrupt from the microphone or from an additional input device when a noise is detected.

User avatar
OutoftheBOTS
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: Efficient sound activated recording

Mon Oct 30, 2017 8:45 pm

yes there r lots of very cheap sound detectors. they simply just emit a high signal when a sound above a certain volume is detected, how load the sound neededs to be is adjustable by just screwing the pot in or out see https://www.aliexpress.com/item/Free-Sh ... 8.9.IcmRSh

dvaosta
Posts: 2
Joined: Mon Oct 30, 2017 9:44 am

Re: Efficient sound activated recording

Wed Nov 01, 2017 8:50 am

Thanks.
So I connect the detector to a port, then I suppose I can use GPIO to associate an interrupt to it, right?

User avatar
OutoftheBOTS
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: Efficient sound activated recording

Thu Nov 02, 2017 1:40 pm

ok I haven;t played with 1 of these myself but have seen others use them successful to do what you want to do.

This is my understanding of them. Hook Vcc to 5v, GND to GND and out to your pin that you want to detect the sound on.

I believe that when a sound is dectected the sensor will pull the out pin to ground

for my code I choose pin 4 for the input pin for the sound.

Code: Select all

import RPi.GPIO as GPIO

INPUT_WIRE = 4

GPIO.setmode(GPIO.BCM)
GPIO.setup(INPUT_WIRE, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

while True: 
  if GPIO.input(INPUT_WIRE) == GPIO.LOW : print" Sound detected"
the code can be shortened to this

Code: Select all

import RPi.GPIO as GPIO

INPUT_WIRE = 4

GPIO.setmode(GPIO.BCM)
GPIO.setup(INPUT_WIRE, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

while True: 
  if not GPIO.input(INPUT_WIRE) : print" Sound detected"

Return to “Python”