In this post we will learn how to make a simple yet effective way to get alerts whenever there is a loud noise/the baby is crying . I do a bit of online gaming so wanted a reliable way to get notified if one of my children was making noise.

I used IFTTT as an alert system but you can choose a different ways to get notified

How it works

Using a raspberry pi zero w and a usb web cam with a mic. We have a script that will detect sound and if that sounds breaches a certain threshold it will then perform an action.

Here’s what you’ll need

Hardware:

  • 1 Raspberry Pi (With wifi) with a power source
  • 1 USB webcam with a microphone
  • 1 micro SD card

Software:

Connect it all up and follow this guide for the OS installation https://www.raspberrypi.org/documentation/installation/installing-images/

Once up and running download the files located on my github https://github.com/NicholasBM/Noisedetector

The noise dector ruby script uses two linux tool to record and analyse the output: sox and arecord. So you need to install these packages on your raspberrypi (or other linux system):

sudo apt-get install sox alsa-utils

Then, in the current version, the script does not accept parameters to change file location (log, tmp recording and pid file), so you need to allow the script execution user (pi for example) the write access to these files and folders:

RECORD_FILENAME='/tmp/noise.wav'
LOG_FILE='/var/log/noise_detector.log'
PID_FILE='/etc/noised/noised.pid'

or you can edit the script and change these variables values with what you prefer for your system.

Edit the main file so that you can trigger an action look for the section #call a url or webhook .

Here you are going to want to update the trigger name and key that you will get from creating a new applet. I had to do this via the platform section of https://platform.ifttt.com the FAQ linked above should get you up and running.

https://maker.ifttt.com/trigger/YOUR_TRIGGER_HERE/with/key/YOUR_KEY_HERE’

Ensure you follow the readme linked on github and once your up and running you can test the service using the parameters below.

noise_detection.rb -m 1 -n 0.30 -e me@server.com -v

where -m is your sound card – e is the email address and -n 0.30 this is the sound threshold that you may want to have a play with this.

I have got rid of the email functionality as no respectable email client accepts sendmail anymore so it was more trouble than it was worth. I will remove the references to it in a later version.

I have the script setup to auto start by editing the rc.local file and example of this is included on github I have also set the script to only run after a certain time of day which you can edit to suit current_time.hour >=20 is anything greater than 20:00 it will fire the webhook if not it will loop.

SHARE
Previous articleRASPBERRY PI ZERO GAMES CONSOLE

NO COMMENTS