toddleplayer is the manual and a bunch of scripts to create an MP3 and Spotify Player controlled through RFID Tags and GPIO Buttons.
Required:
-
A Raspberry Pi: I'm using a Pi Zero W
-
DAC: You can either use a pHAT DAC 15€ or a PCM5102A 3€
-
Any kind of casing: Wooden Box
-
A few push buttons: Push Buttons
-
A Digital Audio Amplifier: PAM8403
-
Passive Speakers: Visaton FR 87
-
A Powerbank or some 18650 Li-Ion Cells and a Power Supply Board
-
A USB RFID READER and USB OTG cable or a MFRC-522
To wire up the cheaper PCMA5102A breakout board you have to wire like this:
PCMA | Raspberry |
---|---|
VCC | 5V PIN 2 |
GND | GND |
FLT | GND |
DMP | GND |
SCL | GND |
BCK | GPIO18 PIN 12 |
DIN | GPIO21 PIN 40 |
LCK | GPIO19 Pin 35 |
FMT | GND |
XMT <–> 10k Resistor <–> 3,3V of the PCM5102A board
Then you wire the L ,G and R Pins of the PCMA to the Input Pins of the PAM. You connect the + and - power pins of the pam8403 directly to the 5V of the Raspberry and GND. Then you connect your speakers to rout/lout + and -.
If you use the pHAT DAC you have to solder it. You can solder all of them or solder them the lazy way.
RC522 | Raspberry |
---|---|
3.3V | 3.3V PIN 1 |
RST | GPIO25 PIN 22 |
GND | GND |
MISO | GPIO9 PIN 21 |
MOSI | GPIO10 PIN19 |
SCK | GPIO11 PIN 23 |
SDA | GPIO8 PIN 24 |
To create this Player you first have to install Pi Musicbox on your local Raspberry. You can download the latest image frome here: RC6
Burn the image to an SD Card with Etcher
-
Put the SD-card into your computer. Ignore the format warning when you're on windows. Open the contents of the 'config' folder of SD-Card in your Finder/Explorer.
-
Open settings.ini and add your Wifi network and password to the file
-
Set
enable_ssh = true
-
Set
output = hifiberry_dac
-
Set
resize_once = true
You can also set your Spotify and Spotify-Web credentials already.
Then you have to put the SD card in the Raspberry and power it up. You can lookup the IP adress on your router. To test your wiring connect to the toddleplayer in the webbrowser and run a radiostream unter the tab Streams.
To connect to the Raspberry use your favorite ssh client like PuTTY.
The standard user is root
and the password is musicbox
.
You have to download the required scripts and unpack them from the latest release.
cd ../
wget https://github.com/tschuehly/toddleplayer/releases/download/test/toddleplayer.zip
unzip toddleplayer.zip
rm toddleplayer.zip
cd toddleplayer/
If you use a USB RFID Reader continue here. If you use the MFRC-522 continue down below with the RC522_music-cards extension.
Next you have to install python evdev.
wget http://dl.piwall.co.uk/python-evdev_0.4.1-1_armhf.deb
dpkg -i python-evdev_0.4.1-1_armhf.deb
Then you have to configure it.
cd music-cards/
python config.py
Select the RFID reader from the inputs. Usually by pressing 0.
sudo nano /boot/config.txt
Find this line and remove the '#':
#dtparam=spi=on
Next, install Python 2.7 dev and gcc using:
sudo apt-get update
sudo apt-get install python2.7-dev
sudo apt-get install gcc
Then download and install the special SPI tool for python with wget.
wget https://github.com/lthiery/SPI-Py/archive/master.zip
unzip master.zip
rm master.zip
cd ./SPI-Py-master
then install it by
sudo python setup.py install
cd ../
Next you have to install python-mpd2 from source here
wget https://github.com/Mic92/python-mpd2/archive/master.zip
unzip master.zip
rm master.zip
cd ./python-mpd2-master
python setup.py install
The easiest way to start the script on startup is to append the following lines to the /opt/musicbox/startup.sh. You have to replace /xxxx/ with either /RC522_music-cards/ or /music-cards/
nohup python -u /toddleplayer/gpio_control.py &> /toddleplayer/gpio.log &
echo "started gpio_control.py"
sleep 15
python -u /toddleplayer/xxxx/box.py &> /toddleplayer/box.log &
echo "started box.py"
Now you can create as many folders as you want in the /music/ folder and add the RFID tags accordingly
python add_card.py
Now you can choose either if you want to add a local folder by pressing [L] or a spotify playlist by pressing [S]
then you have to type in the folder you want to associate with the RFID Card
file:/music/foldername/
To quit you just have to press CTRL + C
The toddleplayer is based on the Pi Musicbox Image: https://github.com/pimusicbox/pimusicbox ,
the music-cards mopidy extension which I altered heavily: https://github.com/fsahli/music-cards ,
the RC522_music-cards project: https://github.com/tschuehly/RC522_music-cards , which uses the MFRC522-python library: https://github.com/mxgxw/MFRC522-python ,
the python-mpd2 library: https://github.com/Mic92/python-mpd2 .
© Thomas Schühly