Soundify: my wifi door chime / siren / loudspeaker with REST API

Tips, Tricks and Scripts to enhance your home automation and workaround known device bugs, limitations and incompatibilities
Post Reply
Posts: 115
Joined: 20 Jul 2015 23:03

Soundify: my wifi door chime / siren / loudspeaker with REST API

Post by fez »

I needed (wanted) a networked door chime to use in my z-wave gateway.
I considered ordering an Aeotec Doorbell, but this is not available in Europe. I looked for other alternatives within the given price range, but I found nothing, so I decided to build my own, which eventually proved to be even cheaper.
Required hardware:
- Raspberry Pi Zero (W): 10€
- Adafruit I2S 3W Class D Amplifier Breakout - MAX98357A, 6€
- a speaker (I've opted for Visaton FR 7, after a failed experiment with a cheaper option), 5€
- a power supply, I just reused a phone charger (consider one capable of 1.2A or more)
- a plastic box, 3€, but I started with a cardboard shoe box

Start by setting up the Raspberry with a Jessie Lite image:

Once you have written the image to the SD card, but still on the PC side, prepare it for headless operation:
- create a "wpa_supplicant.conf" file (to connect later to your wifi network) in the boot folder with the content:

Code: Select all

- create an empty file named "ssh" to have SSH enabled for headless operation

Follow the guide from Adafruit to set up the I2S amplifier: ... d-mono-amp
... until the "Simple MP3 speaker test", the rest you won't be needing
... or you may use a different amp. I found the above to be inexpensive and practical choice.

Add your user to the "audio" group:

Code: Select all

sudo usermod -a -G audio YourUserName 
Install curl:

Code: Select all

apt-get install curl
Download my scripts and mp3 samples to ease the coding:

Code: Select all

curl -L -o ''
chmod +x -R soundify
Try playing an mp3 file/sound:

Code: Select all

~/soundify/ -i ~/soundify/tones/start-sound.mp3 -v 0.1
... the -v parameter sets the volume (accepted 0.01 to 0.99)

Now get rid of the I2S popping/cracking sound by following this guide: ... spberry-pi

Try playing the sound again, twice. Popping should be gone in the second run.

Code: Select all

~/soundify/ -i ~/soundify/tones/start-sound.mp3 -v 0.1
Now get the Flask python module (Jeremy M.'s guide):
sudo apt-get install python-pip
pip install flask[/code]

Start the server by calling the script:

Code: Select all

... the the raspberry should be waiting for commands

Set up a HTTP device to test the web api ( I use my zway gateway for this):

Code: Select all

... use GET, no user, no password

Configure the Raspberry to run the service at boot time:

Code: Select all

sudo nano /etc/rc.local
Add the below line before the "exit 0" :

Code: Select all

# start pulse audio
pulseaudio -D
# play a sound to activate pulse. A (first) popping sound will be followed by the start-sound.
~/soundify/ -i ~/soundify/tones/start-sound.mp3 -v 0.1
# start the REST API server
~/soundify/ & 
You can play any mp3 file placed in the "~/soundify/tones" folder over the web api:
- use GET

Code: Select all

Replace your-raspi-IP, your-mp3-filename, your-volume with real values.
Allowed volumes: 1-99

Authentication is not implemented. Follow Miguel Grinberg's guide to secure the service.

20170802_005402~01~01.jpg (99.93 KiB) Viewed 3507 times

This project is based on the great guides offered by:
- Raspberry Pi Foundation
- Adafruit
- Steven J. Murdoch
- Dan Bader
- Jeremy Morgan
- Miguel Grinberg
- and others
Last edited by fez on 10 Jan 2018 11:43, edited 2 times in total.

Posts: 351
Joined: 08 Aug 2016 17:36

Re: Wifi door chime / siren / loudspeaker with REST API

Post by enbemokel »

Thanks for sharing, I´m looking also for a doorbell, Doorbird e.g.. but it´s very expensive.
Your solution may be also a solution for other places.

Post Reply