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:
https://www.raspberrypi.org/downloads/raspbian
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
network={
ssid="testing"
psk="testingPassword"
}
Follow the guide from Adafruit to set up the I2S amplifier:
https://learn.adafruit.com/adafruit-max ... 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
Code: Select all
apt-get install curl
Code: Select all
curl -L -o soundify.zip 'https://drive.google.com/uc?export=download&id=0B-cIbx13ShdkN2hiOEt3bjRDSHM'
unzip soundify.zip
chmod +x -R soundify
Code: Select all
~/soundify/sound.py -i ~/soundify/tones/start-sound.mp3 -v 0.1
Now get rid of the I2S popping/cracking sound by following this guide:
https://www.lightbluetouchpaper.org/201 ... spberry-pi
Try playing the sound again, twice. Popping should be gone in the second run.
Code: Select all
~/soundify/sound.py -i ~/soundify/tones/start-sound.mp3 -v 0.1
sudo apt-get install python-pip
pip install flask[/code]
Start the server by calling the script:
Code: Select all
~/soundify/shout.py
Set up a HTTP device to test the web api ( I use my zway gateway for this):
Code: Select all
http://your-raspi-IP:5000/shout/api/v1.0/doorbell1.mp3/49
Configure the Raspberry to run the service at boot time:
Code: Select all
sudo nano /etc/rc.local
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/sound.py -i ~/soundify/tones/start-sound.mp3 -v 0.1
# start the REST API server
~/soundify/shout.py &
- use GET
-
Code: Select all
http://your-raspi-IP:5000/shout/api/v1.0/your-mp3-filename/your-volume
Allowed volumes: 1-99
Authentication is not implemented. Follow Miguel Grinberg's guide to secure the service.
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