Inspired by Toniebox but too cheap to buy one. Can not resist building your own? Could not get the installtion for Phoniebox to work so , bored by COVID19 lockdown here is a simple Python engine for RFID card enabled MP3 players on a Raspberry Pi.
Here's a list of required hardware with Amazon links that I purchased. They can vary I think, especially the Raspberry Pi and the speaker.
- Raspberry Pi 4
- RFID Reader
- USB Speaker I was reading the 3.5 Rasbperry output usuall had a hum, so I opeted for the digital USB speaker solution.
- MicroSD
- PI Cover
- RFID Cards , I think you can also use RFID FOBs ans attach them to stuffed animals. But we opted for cards because you can paint on them.
- A box / container for the final Jukebox. We used a old gift box because of COVID19 lockdown, but planned to go through antigque shops for nicer solutions. RFID cards allow to customize the cards in any way you like.
Download the headless Rasbian Buster release and follow the instructions how to flash the iso onto the MicroSD card. On a Mac, Etcher ran without any issue.
Next, enable Wifi connectivity on installed operating system.
Run touch /Volumes/boot/ssh
to enable ssh
on the headless Rasbian.
Copy
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="NETWORK_ID"
psk="PASSWORD"
}
into
/Volumes/boot/wpa_supplicant.conf
(Note, the above path is for Macs, the mounted MicroSD might be in a different location if you are on Windows or Linux)
The Rapsberry with the now configured MicroSD should now be accessible through the your Wifi.
Connect through ssh pi@REPLACE_PI_IP_HERE
. The default pi
password on Buster
is raspberry
.
Now, on the PI install the dependencies
sudo apt install vim
sudo apt install ipython3
sudo apt install python3-pip
sudo apt install evtest
sudo pip3 install evdev
sudo pip3 install python-vlc
Run evtest
and lsusb
. If no other USB device is plugged to the PI, evtest
will output the RFID device path.
Create a JSON file of the format
{
"RFID_CODE" : "/path/to/a/audio/file.mp3"
}
<install_path>/jukebox.py --db <your_db>.jdbd -i /dev/event/rfid_reader_id