application | ||
audio | ||
contrib | ||
hardware/case | ||
.gitignore | ||
luniebox.sh | ||
README.md |
luniebox
lunibox is a RFID jukebox based on a Raspberry Pi. It is similar to the Phoniebox [GitHub] and an upgrade of the TonUINO (de) which both are DIY versions of the popular Toniebox©. The main focus for now is to play Spotify© content and playing local files (also supports Spotify© download for offline use). Other sources will be integrated later.
Prerequisites
You need to be familiar with ssh (Putty on Windows). For the usage of Spotify© a premium account is required.
Hardware
- Raspberry Pi (tested with Raspberry Pi 3 Model B, Zero 2 W) [starting at ~14€]
- power supply (5V ~2.5A) [starting at ~6€]
- Micro SD card (at least 4GB) [starting at ~4€]
- RC522 RFID Reader [starting at ~1.50€]
- RFID (MiFare) cards or chips [starting at ~2€]
- a Audio Card:
- Pimoroni Audio Amp SHIM (3W Mono Amp) [starting at ~11€] with passive speaker [starting at ~5€]
- Pimoroni Audio DAC SHIM [starting at ~14€] with active speaker
- Adafruit Speaker Bonnet for Raspberry Pi
- ...something else (use custom setup!)
- (optional) 2x Push Buttons for volume control [starting at ~1€]
- (optional) MPU9250 9-axis sensor [starting at ~1.50€]
- (optional) Waveshare UPS HAT + 2x 18650 18650 Li battery [starting at ~30€]
- some wires or dupont connectors [starting at ~2€]
- case for all above
- depending on hardware: soldering equipment
A minimal setup (Raspberry Zero 2 W, power supply, Micro SD, RC522, Cards, Audio Amp, Speaker, Buttons) should be about ~45€ plus case materials.
Software
- latest Raspberry Pi OS blank installation on Micro SD card (Instructions: raspberrypi.com/software/)
- WiFi connection
- ssh enabled
Optional: Headless installation
If you're using a Raspberry Pi Zero or have missing peripherals to setup WiFi and ssh please perform the following steps:
- insert Micro SD card with Raspberry Pi OS into a computer
- place an empty file called
ssh
into/boot
folder/partioon - place a filed called
wpa_supplicant.conf
into/boot
folder/partition with following contentcountry=$COUNTRY_CODE ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="$WIFI_SSID" psk="$WIFI_PASSWORD" }
- replace
$COUNTRY_CODE
with upper-case country code (eg. GB or DE) and$WIFI_SSID
and$WIFI_PASSWORD
with your WiFi credentials - plug card back into your Pi and connect power supply
Setup
Open terminal on your pi or establish a ssh connection to your Pi:
- the Pi should be reachable under
raspberrypi
orraspberrypi.local
in your network, if not try to find out it's IP address from your router. - default username is
pi
and default password israspberry
- Example:
ssh pi@raspberrypi.local
orssh pi@192.168.2.100
⚠️ Warning: you should change the default password by executing
passwd
after login
Automatic setup
⚠️ Warning: executing scripts from the internet without checking is bad. This is only done to get things done fast. In any doubts you can perform the Manual setup and execute all commands step-by-step to understand what's going on.
Download and execute the luniebox.sh
script to go trough an interactive setup process. You can also pass the -a
argument to skip any prompts. Use the -h
argument for detailed parameter to configure automatic setup directly.
-
download and excecute setup script from web
-
interactive
bash <(curl -s https://git.bstly.de/Lurkars/luniebox/raw/branch/main/luniebox.sh)
-
full automatic
bash <(curl -s https://git.bstly.de/Lurkars/luniebox/raw/branch/main/luniebox.sh) -a
-
-
Alternative first download script, take a look and then execute
curl https://git.bstly.de/Lurkars/luniebox/raw/branch/main/luniebox.sh -o luniebox.sh chmod +x luniebox.sh
-
interactive
./luniebox.sh
-
full automatic
./luniebox.sh -a
-
Manual setup
Software setup
-
go to home directory
cd /home/pi
-
install
git
,python3-venv
andpython3-pip
sudo apt install -y git python3-venv python3-pip
-
clone repository
https://git.bstly.de/Lurkars/luniebox.git
with sources and config:git clone https://git.bstly.de/Lurkars/luniebox.git luniebox
Setup luniebox application and daemon
-
setup application by building python venv and setup systemd service
cd /home/pi/luniebox/application python -m venv venv source venv/bin/activate export CFLAGS=-fcommon pip install -r requirements.txt deactivate mkdir /home/pi/luniebox/config cp /home/pi/luniebox/contrib/config/luniebox.cfg /home/pi/luniebox/config/luniebox.cfg sudo cp /home/pi/luniebox/contrib/service/luniebox-app.service /etc/systemd/system/ sudo cp /home/pi/luniebox/contrib/service/luniebox-daemon.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable luniebox-app luniebox-daemon
Setup spotify
For Spotify support, spofiyd is required.
-
get spotifyd binary and setup systemd service
mkdir /home/pi/luniebox/bin` wget -c https://github.com/Spotifyd/spotifyd/releases/download/v0.3.3/spotifyd-linux-armv6-slim.tar.gz -O - | tar -xz -C /home/pi/luniebox/bin cp /home/pi/luniebox/contrib/config/spotifyd.cfg /home/pi/luniebox/config/spotifyd.cfg sudo cp /home/pi/luniebox/contrib/service/spotifyd.service /etc/systemd/system/` sudo systemctl daemon-reload` sudo systemctl enable spotifyd
ℹ️ If you use other audio hardware, you may need to adjust the
backend
anddevice
property in/home/pi/luniebox/config/spotifyd.cfg
to your needs!
Setup Music Player Daemon
for offline file support setup Music Player Daemon (mpd)
-
create library folder and install
mpd
mkdir /home/pi/luniebox/library sudo apt install -y mpd sudo cp /home/pi/luniebox/contrib/config/mpd.conf /etc/mpd.conf
ℹ️ If you use other audio hardware, you may need to adjust the
audio_output
in/etc/mpc.conf
section to your needs!
Setup ClSpotify
for Spotify offline support setup ClSpotify (requires spotify and mpd!).
-
get code, install pythen venv and update config
git clone https://github.com/agent255/clspotify.git /home/pi/clspotify cd /home/pi/clspotify python -m venv venv source venv/bin/activate pip install -r requirements.txt deactivate sed -i "s/^zspotify_path =.*$/zspotify_path = \/home\/pi\/clspotify\//" /home/pi/luniebox/config/luniebox.cfg
Hardware Setup
For a detailed Raspberry Pi pinout take a look at https://pinout.xyz.
Setup RC522 RFID Reader
-
uncomment
dtparam=spi=on
in/boot/config.txt
tp enable SPI for RC522sudo sed -i "/dtparam=spi=on/s/^#//g" /boot/config.txt
-
connect RC522
- SDA to Pin 24 [GPIO 8 / SPI0 CE0]
- SCK to Pin 23 [GPIO 11 / SPI0 SCLK / CLK]
- MOSI to Pin 19 [GPIO 10 / SPI0 MOSI]
- MISO to Pin 21 [GPIO 9 / SPI0 MISO]
- GND to Pin 20 [Ground]
- RST to Pin 22 [GPIO 25]
- 3.3v to Pin 1 [3v3 Power]
Setup Pimoroni Amp or DAC
-
disable onboard audio comment out
dtparam=audio=on
in/boot/config.txt
sudo sed -i "/dtparam=audio=on/s/^/#/g" /boot/config.txt
-
setup hifiberry-dac by adding following content to
/boot/config.txt
# setup hifiberry for Pimoroni Shim dtoverlay=hifiberry-dac gpio=25=op,dh
printf "\n# setup hifiberry for Pimoroni Shim\ndtoverlay=hifiberry-dac\ngpio=25=op,dh\n" | sudo tee -a /boot/config.txt
Setup Adafruit Speaker Bonnet for Raspberry Pi
-
disable onboard audio comment out
dtparam=audio=on
in/boot/config.txt
sudo sed -i "/dtparam=audio=on/s/^/#/g" /boot/config.txt
-
setup hifiberry-dac and i2s by adding following content to
/boot/config.txt
# setup hifiberry and i2s for Adafruit Speaker Bonnet dtoverlay=hifiberry-dac dtoverlay=i2s-mmap
printf "\n# setup hifiberry and i2s for Adafruit Speaker Bonnet\ndtoverlay=hifiberry-dac\ndtoverlay=i2s-mmap\n" | sudo tee -a /boot/config.txt
-
copy contrib/config/asound.conf to
/etc/asound.conf
.cat /home/pi/luniebox/contrib/config/asound.conf | sudo tee /etc/asound.conf
-
copy contrib/config/.asoundrc to
/home/pi/.asoundrc
.cat /home/pi/luniebox/contrib/config/.asoundrc | tee /home/pi/.asoundrc
Setup Push Buttons
-
connect first push button (volume down)
- Pin 8 [GPIO 14]
- Pin 6 [Ground]
-
connect second push button (volume up)
- Pin 7 [GPIO 4]
- Pin 9 [Ground]
Setup MPU9250 9-axis sensor
-
install
i2c-tools
andpython3-smbus
sudo apt install -y i2c-tools python3-smbus
-
uncomment
dtparam=i2c_arm=on
in/boot/config.txt
to enable I2C for MPU9250sudo sed -i "/dtparam=i2c_arm=on/s/^#//g" /boot/config.txt
-
setup i2c bus 4 for MPU9250 by adding following content to
/boot/config.txt
# setup ic2 bus 4 for mpu dtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24
printf "\n# setup i2c bus 4 for mpu\ndtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24\n" | sudo tee -a /boot/config.txt
-
connect MPU9250
- SDA to Pin 16 [GPIO 23]
- SCL to Pin 18 [GPIO 24]
- GND to Pin 14 [Ground]
- 3V3 to Pin 17 [3v3 Power]
Finish Setup
-
After setup, reboot system.
sudo reboot
Planned features
- status LEDs
- indicators for UPS HAT
- WiFi Hotspot (https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/158-raspberry-pi-auto-wifi-hotspot-switch-direct-connection)