-
Notifications
You must be signed in to change notification settings - Fork 407
CONFIGURE
Important: Please prefer to use the One line install command for installation, which will configure Phoniebox automatically
This is the second step. Make sure to go through the installation first.
Once you finished with the configuration, read the manual to add audio files and RFID cards.
MUST READ: if you encounter problems, please read this page in the wiki: RFID Reader Special
The RFID reader is connected to your RPi via USB. As you plug it in, it should have made a 'beep'. And each time you swipe a keyring or card across the card reader, it should also make a 'beep'.
Let's see if your reader is probably connected and recognised by your RPi. Check the following:
- The LED on the reader is on.
- When swiping a card or keyring, you hear a 'beep' noise.
If you can answer both with yes, you can be 90% sure all is working well. Just to be 100% sure, here are a few command to type on the command line which should list your reader.
ls -la /dev/input/by-id/
In my case, this will list the Barcode Reader and show that the system can interact with the device under event0
:
lrwxrwxrwx 1 root root 9 Apr 30 09:55 usb-Sycreader_USB_Reader_08FF20150112-event-kbd -> ../event1
Now we know a lot about the RFID reader attached to our RPi. In order to use it as a controller for our Phoniebox, the software needs to know which device to listen to.
To register your device, go to the directory containing all the scripts and run the file RegisterDevice.py
.
cd /home/pi/RPi-Jukebox-RFID/scripts/
python3 RegisterDevice.py
This will bring up a list of one or more devices. Spot the device you are using as a RFID reader, type the number (in this case 2) and hit Enter.
Choose the reader from list
0 Chicony USB Keyboard
1 Chicony USB Keyboard
2 Sycreader USB Reader
3 Logitech USB-PS/2 Optical Mouse
You can check if your device was registered properly by taking a look inside the file that was just generated, called deviceName.txt
.
cat deviceName.txt
Now your Phoniebox knows which device to listen to when you are swiping your cards or keyrings.
Inside the directory /home/pi/RPi-Jukebox-RFID/settings/
you find the file rfid_trigger_play.conf.sample
You need to make a copy of this files, to avoid overwriting changes if the content might change in the git repo.
Inside this conf
file, you can add IDs from RFID cards to control
the functionality of the Phoniebox. See the content of the file for
more explanation.
cd /home/pi/RPi-Jukebox-RFID/settings/
cp rfid_trigger_play.conf.sample rfid_trigger_play.conf
sudo chown pi:pi rfid_trigger_play.conf
sudo chmod 665 rfid_trigger_play.conf
Creating files for the settings
folder which contain the short name
of the amixer iface used and the percentage the volume increase or
decreases when using the volumeup
and volumedown
function.
Troubleshooting:
- Inside
settings/Audio_iFace_Name
is the iFace name of the sound card. By default for the RPi this would bePCM
. But this does not work for every setup. If you are using phatbeat as a DAC for example, you need to change the content ofAudio_iFace_Name
fromPCM
toMaster
orSpeaker
. Other external sound cards might use different interface names. To see ifPCM
could work for you, typeamixer sget PCM
. To list all available iFace names, typeamixer scontrols
. - If one is using an audio amplifier (like the pHAT BEAT) without a physical volume limiter (like a potentiometer) your Phoniebox can get very loud "accidentally". The maximal volume can be set in
settings/Max_Volume_Limit
.
echo "PCM" > /home/pi/RPi-Jukebox-RFID/settings/Audio_iFace_Name
echo "3" > /home/pi/RPi-Jukebox-RFID/settings/Audio_Volume_Change_Step
echo "100" > /home/pi/RPi-Jukebox-RFID/settings/Max_Volume_Limit
echo "0" > /home/pi/RPi-Jukebox-RFID/settings/Idle_Time_Before_Shutdown
Music Player Daemon (MPD) is a flexible, powerful, server-side application for playing music. Through plugins and libraries it can play a variety of sound files while being controlled by its network protocol. While MPD is running in the background, MPC acts like a player 'on top'.
You need to change the configuration file.
sudo nano /etc/mpd.conf
Find these options and change to the following:
music_directory "/home/pi/RPi-Jukebox-RFID/shared/audiofolders"
playlist_directory "/home/pi/RPi-Jukebox-RFID/playlists"
user "root"
-
auto_update "yes"
(you have to remove the # in front of that line) -
auto_update_depth "10"
(remove the # and change the value to 10) -
mixer_control "yourAudioIfaceNameHere"
(you need to uncomment this line and change the audio iFace shortname)
Maybe you need to change the audio iFace ("yourAudioIfaceNameHere") in the config file, too. By default it uses PCM
which should work out of the box. If it doesn't, type in terminal:
amixer scontrols
This should create an output similar to this:
Simple mixer control 'Speaker',0
Simple mixer control 'Mic',0
Simple mixer control 'Auto Gain Control',0
In which case, instead of PCM
you need to use Speaker
.
Then you need to update mpc
:
mpc update
To make the Phoniebox easy to administer, it is important that you can add new songs and register new RFID cards over your home network. This can be done from any machine. The way to integrate your RPi into your home network is using Samba, the standard Windows interoperability suite for Linux and Unix.
Open a terminal and install the required packages with this line:
sudo apt install samba samba-common smbclient
First, let's edit the Samba configuration file and define the workgroup the RPi should be part of.
sudo nano /etc/samba/smb.conf
Edit the entries for workgroup and wins support:
workgroup = WORKGROUP
wins support = yes
If you are already running a windows home network, add the name of the network where I have added WORKGROUP
.
Now add the specific folder that we want to be exposed to the home network in the smb.conf
file.
[phoniebox]
comment=Pi Jukebox
path=/home/pi/RPi-Jukebox-RFID/shared
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=no
veto files=/._*/.DS_Store/
Note: the path
given in this example works (only) if you are installing the Phoniebox code in the directory /home/pi/
.
If the audio files are not inside the shared
folder, you might want to add another section to the config file. Otherwise you can not manage audio files over the samba / windows network. This might look like this - changing the path to your needs:
[phoniebox_audio]
comment=Pi Jukebox
path=/path/to/audiofolders
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=no
veto files=/._*/.DS_Store/
Finally, add the user pi
to Samba. For simplicity and against better knowledge regarding security, I suggest to stick to the default user and password:
user : pi
password : raspberry
Type the following to add the new user:
sudo smbpasswd -a pi
There is a second way to control the RFID Phoniebox: through the browser. You can open a browser on your phone or computer and type in the static IP address that we assigned to the RPi earlier. As long as your phone or PC are connected to the same WiFi network that the RPi is connected to, you will see the web app in your browser.
The Phoniebox web app allows to upload files through the web app. To do so, php needs to understand that it is allowed to ignore files sizes and maximum size per file and the like. Such restrictions are set in the file /etc/php/7.0/fpm/php.ini
. What you need to change (or use the sample script in the following step) are these variables - they need to be changed to read like the following:
file_uploads = On
upload_max_filesize = 0
max_file_uploads = 20
post_max_size = 0
Copy the php.ini
file to the right place and change the user and access rights:
sudo cp /home/pi/RPi-Jukebox-RFID/misc/sampleconfigs/php.ini.stretch-default.sample /etc/php/7.0/fpm/php.ini
sudo chown root:root /etc/php/7.0/fpm/php.ini
sudo chmod 644 /etc/php/7.0/fpm/php.ini
If you don't want to reboot your Phoniebox, you need to restart php7.0-fpm
to load the new php.ini
file.
sudo service php7.0-fpm restart
There is a sample config file in the htdocs
folder which you need to copy to config.php
.
This assures that you can make changes to config.php
which will not be affected by updates
in the upstream repository.
sudo cp /home/pi/RPi-Jukebox-RFID/htdocs/config.php.sample /home/pi/RPi-Jukebox-RFID/config.php
Make sure the shared
and htdocs
folders are accessible by the web server:
sudo chown -R pi:www-data /home/pi/RPi-Jukebox-RFID/shared
sudo chmod -R 775 /home/pi/RPi-Jukebox-RFID/shared
sudo chown -R pi:www-data /home/pi/RPi-Jukebox-RFID/htdocs
sudo chmod -R 775 /home/pi/RPi-Jukebox-RFID/htdocs
If your audiofiles are not in the shared
folder, you may want to make them accessible by the web server as well:
sudo chown -R pi:www-data /path/to/your/audiofiles
sudo chmod -R 775 /path/to/your/audiofiles
This is the final tweak to the configuration: automatically start our Phoniebox software after the RPi has booted and have it listen to RFID cards. The Raspbian OS 9 (stretch) uses systemd to start the components.
Systemd will launch the required services after booting AND take care of restarting the script in case they die.
First copy the service config files to the correct directory:
sudo cp /home/pi/RPi-Jukebox-RFID/misc/sampleconfigs/phoniebox-rfid-reader.service.stretch-default.sample /etc/systemd/system/phoniebox-rfid-reader.service
sudo cp /home/pi/RPi-Jukebox-RFID/misc/sampleconfigs/phoniebox-startup-sound.service.stretch-default.sample /etc/systemd/system/phoniebox-startup-sound.service
sudo cp /home/pi/RPi-Jukebox-RFID/misc/sampleconfigs/phoniebox-gpio-control.service.sample /etc/systemd/system/phoniebox-gpio-control.service
sudo cp /home/pi/RPi-Jukebox-RFID/misc/sampleconfigs/phoniebox-idle-watchdog.service.sample /etc/systemd/system/phoniebox-idle-watchdog.service
Now systemd has to be notified that there are new service files:
sudo systemctl daemon-reload
Now enable the service files, which will start them on reboot:
sudo systemctl enable phoniebox-idle-watchdog
sudo systemctl enable phoniebox-rfid-reader
sudo systemctl enable phoniebox-startup-sound
sudo systemctl enable phoniebox-gpio-control
And now you can reboot to have your daemons running or start them manually:
sudo systemctl start phoniebox-idle-watchdog
sudo systemctl start phoniebox-rfid-reader
sudo systemctl start phoniebox-startup-sound
sudo systemctl start phoniebox-gpio-buttons
The newly installed service can be started either by rebooting the Phoniebox or
with:
sudo systemctl start phoniebox-rfid-reader
To see if the reader process is running use the following command:
sudo systemctl status phoniebox-rfid-reader
This should produce an output like this:
pi@Jukebox:~ $ systemctl status phoniebox-rfid-reader
* phoniebox-rfid-reader.service - RFID-Reader Service
Loaded: loaded (/etc/systemd/system/phoniebox-rfid-reader.service; enabled; vendor pres
Active: active (running) since Fri 2018-04-13 07:34:53 UTC; 5h 47min ago
Main PID: 393 (python2)
CGroup: /system.slice/phoniebox-rfid-reader.service
ββ393 /usr/bin/python2 /home/pi/RPi-Jukebox-RFID/scripts/daemon_rfid_
Apr 13 07:34:53 Jukebox systemd[1]: Started RFID-Reader Service.
The mp3s for startup and shutdown sound have to be copied to the right folder. You may use your own sound files as well.
cp /home/pi/RPi-Jukebox-RFID/misc/sampleconfigs/startupsound.mp3.sample /home/pi/RPi-Jukebox-RFID/shared/startupsound.mp3
cp /home/pi/RPi-Jukebox-RFID/misc/sampleconfigs/shutdownsound.mp3.sample /home/pi/RPi-Jukebox-RFID/shared/shutdownsound.mp3
Ok, after all of this, it's about time to reboot your Phoniebox. Make sure you have the static IP address at hand to login over SSH after the reboot.
sudo reboot
Once the software is all in place, make sure the hardware is connected correctly.
- Connect a USB hub with the power supply. From this hub, connect the RPi to one plug and the USB powered speakers to another. Do not connect the speakers to the USB of the RPi, because the power coming from the RPi might not be enough to run the speakers.
- You need a number of USB plugs to connect the following and therefore possibly need a second USB hub to connect to the RPi USB:
- RFID card reader
- WiFi dongle (WLAN adapter for RPi < version 3)
- External soundcard (optional)
- Connect the speakers with the 3.5mm jack to the soundcard (either the built in one from the RPi or the external one attached to the RPi over USB).
In order to use an external USB soundcard instead of the inbuilt audio out, you might need to update your system and tweak a couple of config files, depending on your card. The most comprehensive explanation on why and how, you can find at adafruit.
Using the Jessie distribution, you might be lucky and there is a quick fix setting the ~/.asoundrc file.
Adding control buttons for volume, skipping tracks, pause, play, read the GPIO buttons installation guide.
Now the installation and configuration are complete. Time to read the manual of the Phoniebox to add songs, web streams, register new cards and so on. Read the Manual.
If you like Phoniebox, consider: buy me a coffee or PayPal
- Code: https://github.com/MiczFlor/RPi-Jukebox-RFID
- Phoniebox home page: English | Deutsch
Phoniebox is a contactless jukebox for the Raspberry Pi, playing audio files, playlists, podcasts, web streams and spotify triggered by RFID cards. All plug and play via USB, no soldering iron needed. Update: if you must, it now also features a howto for adding GPIO buttons controls.
Visit Phoniebox.de
π₯ Version 3
- β Releases
- π΅ Install Jukebox Version 3
- π Report a bug
- π Propose a feature
- βοΈ Feature Status
- π Documentation
- π©βπ» Development
- βοΈ Contributing
- π¦ Code
πΆ Version 2
- β Releases
- π΅ Install Jukebox Version 2
- π Report a bug
- βοΈ Features
- π Documentation
- βοΈ Contributing
- π¦ Code
Version 2 Pages
-
Setup / Upgrades
- Synchronising Phonieboxes in a local network
- Smart Home remote control with MQTT
- Hardware Pinout Overview
- Systemwide Equalizer
- Phoniebox with read-only Filesystem
- HiFiBerry Soundcard Details
- WM8960 Hi-Fi HAT
- PAM8403 Amplifier Power Off
- TPA3118 Amplifier Power Off and EMI improvement
- External Non USB Audio DAC ES9023, PCM5102, etc.
- On-board LEDs with fibre optics
- Setting GPIOs at boot time
- Stop on removal with USB RFID Reader
- Firmware update improves audio out
- Architecture