Very simple setup for a music box which runs different kind of shell scripts based on codes from NFC cards. I build this box for my 1 year-old daughter and she loved it :)
Project is inspired by voss.earth "Jukebox für Kinder" blog - Most of the parts used in this Aribox, are already listed in this blog article.
There are quite interesting concepts, e.g. switching on and off a WIFI USB dongle on a raspberry.
Thank you https://github.com/ondryaso/pi-rc522 for building the documentation and python library for the PI-RC522 :)
sudo apt-get update
sudo apt-get install python3 python3-venv python3-pip
sudo apt-get install python3-gpiozero
sudo apt-get install python-alsaaudio
pip3 install -r requirements.txt
to install the project
pip3 install -e .
sudo visudo /etc/sudoers
Append to the file:
# Allow pi to shutdown without being pwd
pi raspberrypi =NOPASSWD: /usr/bin/systectl poweroff,/usr/bin/systemctl halt,/usr/bin/systemctl reboot`
To save and close in visudo
ctrl + o
+ctrl + x
Enabled commands:
sudo systemctl poweroff
sudo systemctl reboot
sudo systemctl halt
Before running the box you need to create a songs
folder and add a start.wav and stop.wav.
To enable the service definition aribox.service
run sudo systemctl enable aribox.service
which will register the service to be run on system boot.
Here are some inspirational images how inside the Aribox things are wired up. Maybe it helps.
- I was not able to figure out the optimal startup time for the box. It seems the external sound card needs some boot time. If the aribox.service starts to early after system startup, the driver is not initialized properly (15s seems to be working - however, my daughter does not really like to wait :D)
- Sometimes the RFC reader does not get signals properly when a card is not removed from the top of the reader. I added a 2s threshold for the time a card needs to be removed for the reader before replaying. However, sometimes the song gets replayed without removing the card form the reader.