Portable Musicbox
[TOC]
What do you need?
Hardware
- Raspberry Pi, at least Version 3B
- TFT Display
- Rotary Encoder
- Hifiberry MiniAmp or maybe an Infineon MERUS
- two small Speakers, for example Visaton FRS8
- USV hat, for example Geekworm/SupTronics X750
- RTC
- SDCard where the OS is running from
- USB Stick where all your local music is stored
- a bunch of cables like USB, HDMI and power extension cables
Software
- Volumio
- or Mode or rAudio?
- ...a lot of time
Download Volumio and put it on SD Card
see Quick-Start-Guide-Volumio.pdf
Initial setup
see step (5. Volumio configuration on the Web-UI).
If it comes to the third step ("Configure your DAC - Audio Output") choose the DAC device:
Hifiberry Miniamp
Go to Volumio playback settings.
Soundcard: Hifiberry Dac
Mixer Type: Software
After everything is setup you have to reboot and connect to device via your chosen device name with an additional .local, for e.g. volumio.local.
Set volume options
- Einstellungen > Wiedergabeoptionen > Lautstärke-Einstellungen > Art des Mischers: Software > Speichern
- Standard-Lautstärke: 20
- Lautstärke-Schritt pro Klick: 4 > Speichern
Privacy settings
Systemeinstellungen > Privacy settings > Allow UI Statistics Collection: enable or disable by your preference
Plugins
Install
- Music Services
- Spotify 2.0.3 / allows browsing your Spotify playlists, albums, artists inside Volumios UI
- Volumio Spotify Connect2 1.0.5 / allows seemless switching of devices with "My Devices" in Spotify Web and Apps
- Miscellanea
- Amplifier Switch 0.1.2
- System Tools
- -GPIO Buttons 0.8.1-
- GPIO Control 0.0.1
- -Backup & Restore Data 0.7.2-
- User Interface
- Rotary Encoder 1.2.2
Configure plugins
Amplifier Switch 0.1.2
- Output: 16
Spotify
- set Username & Password > Authorize
Volumio Spotify Connect2
- Multi-User Device: off
GPIO Control
BCM27 / Pin 13 / Volumio Status LED / on if loaded and configured via GPIO Control Plugin
Rotary Encoder
First Rotary Encoder settings:
- CLK: 5
- DT: 6
- SW: 13
- Coding: Default
- Detent Action: Control volume
- Button Action: Toggle play/pause
- Long press Action: Stop
Conclusion
Don't forget to set the volume once. It still stays on 100%.
After that you should now be able to play your first track from local USB storage (Musikbibliothek), NAS or Spotify - whatever you prefer. Hit the PLAY button.
Some sweets
Let's add some sweets.
SSH
Go to http://musicbox.local/dev/ and enable SSH via one-click button. Enable Live Log if you want to. Log in via SSH with putty/kitty/your preferred SSH client.
Copy content of userconfig.txt to /boot/userconfig.txt. This file is already included out-of-the-box in /boot/config.txt. It will contain persistent tweaks and configurations, like
- no boot delay
- enabling SPI (for Display)
- I2C (DS1307 RTC)
- disabling power consuming LEDs
- underclocking
Example of userconfig.txt
Disable force_turbo=0 if something goes weird.
# Add your custom config.txt options to this file,
# which will be preserved during updates
boot_delay=0
dtparam=spi=on # required by: TFT Display
dtoverlay=i2c-rtc,ds1307 # rquired by: RTC clock
#dtoverlay=spi1-1cs
# Disable on-board LEDs to save power of around 30mA
## ACT LED.
dtparam=act_led_trigger=none
dtparam=act_led_activelow=off
# PWR LED.
dtparam=pwr_led_trigger=none
dtparam=pwr_led_activelow=off
# underclock 3B+ / power saving here is actually
#force_turbo=0 # comment this out if something gets wrong
over_voltage=-2 # reduce cpu voltage by 2*0,25V
arm_freq=1200 # std=1400
arm_freq_min=400 # std=600
core_freq=350 # std=400
core_freq_min=200 # std=250
# dtoverlay=sdtweak,overclock_50=100
# avoid_warnings=2
# initial_turbo=30
Underclocking and power consumption details:
https://www.raspberrypi.org/documentation/configuration/config-txt/overclocking.md
https://magpi.raspberrypi.org/articles/how-to-overclock-raspberry-pi-4
https://www.foxplex.com/sites/raspberry-pi-over-und-underclocking/
https://learn.pi-supply.com/make/how-to-save-power-on-your-raspberry-pi/
Before you install any additional software do an update
DON'T DO THIS !!!
> sudo apt-get update
> apt-get upgrade
dist-upgrade is known to break volumio, especially MPD will be broken. See Troubleshooting section.
RTC
Set a timezone: > ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
Setup
SPI should be already enabled via /boot/userconfig.txt (dtoverlay=i2c-rtc,ds1307).
Install Python i2c-tools (already installed in Volumio v2.861) and SMBus:
> sudo apt-get install python-smbus i2c-tools
Check if hardware is found by running
> sudo i2cdetect -y 1
to see the UU show up on address 0x68.
Disable the "fake hwclock" which interferes with the 'real' hwclock
> sudo apt-get -y remove fake-hwclock
> sudo update-rc.d -f fake-hwclock remove
> sudo systemctl disable fake-hwclock
Now with the fake-hw clock off, you can start the original 'hardware clock' script.
Run sudo nano /lib/udev/hwclock-set and comment out these three lines:
#if [ -e /run/systemd/system ] ; then
# exit 0
#fi
Also comment out the two lines
/sbin/hwclock --rtc=$dev --systz --badyear
/sbin/hwclock --rtc=$dev --systz
Check time the first time. You can read the time directly from the RTC with sudo hwclock -r. Plug in Ethernet or WiFi to let the Pi sync the right time from the Internet. Once that's done, run sudo hwclock -w to write the time, and another sudo hwclock -r to read the time.
You just have to do the above steps once.
Source:
> https://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/set-rtc-time
USV/UPS
Geekworm X750
(https://raspberrypiwiki.com/X750#User_Manual)
ups-x750-check.service checks and shuts down the Pi if capacity is reaching a critical level
ups-shutdown.service is for the power button
Create folder /home/volumio/log with 755 rights.
Copy x750pwr.sh and ups-x750-check.py to /home/volumio/ups/.
Set rights of sh script:
> sudo chmod +x /home/volumio/ups/x750pwr.sh
Copy ups-shutdown.service and ups-x750-check.service to /lib/systemd/system and run:
> systemctl enable ups-shutdown
> systemctl start ups-shutdown
> systemctl enable ups-x750-check
> systemctl start ups-x750-check
Check both if they are runnging correctly:
> systemctl status ups-shutdown
> systemctl status ups-x750-check
Both should be green.
Bluetooth
Builtin in Volumio. Just enable it in settings.
Display
SPI already enabled in userconfig.txt (dtparam=spi=on).
Edit
> sudo nano /etc/modules
and add
> spi-bcm2835
Install build tools
> sudo apt-get install --reinstall make
> sudo apt-get install build-essential
Installing necessary python libraries (e.g. Image (Pillow), SPI, RPi.GPIO)
> sudo apt-get install python-dev python-setuptools python-pip python-rpi.gpio
> sudo apt-get install libjpeg-dev zlib1g-dev libfreetype6-dev # necessary for Pillow
> /usr/bin/pip install pillow==6.2.2 spidev netifaces gpiozero --user
Pillow 6.2.2 is the latest version which supports Python 2.7.x
--------------------------------------------------------------------
PIL SETUP SUMMARY
--------------------------------------------------------------------
version Pillow 6.2.2
platform linux2 2.7.9 (default, Sep 26 2018, 05:58:52)
[GCC 4.9.2]
--------------------------------------------------------------------
--- JPEG support available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBIMAGEQUANT support not available
*** LIBTIFF support not available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library and headers.
See https://pillow.readthedocs.io/en/latest/installation.html#building-from-source
To check the build, run the selftest.py script.
Clone Volumio plugin from Github
> git clone https://github.com/one-step-behind/tft24-plugin
> cd tft24-plugin
> volumio plugin install
Copy scripts and run them
- Copy the display scripts (
fonts,img,lib_tft24T.py,volumio-display.py,volumio-display-startup.py) into/home/volumio/volumio-display. - Copy systemd scripts (
volumio-display.service,volumio-display-startup.service) to/lib/systemd/system. - Run:
> systemctl enable volumio-display-startup
> systemctl start volumio-display-startup
> systemctl enable volumio-display
> systemctl start volumio-display
Check both if they are runnging correctly:
> systemctl status volumio-display-startup
> systemctl status volumio-display
Both should be green.
Troubleshooting
GPIO readall errors
gpio readall shows error: Oops - unable to determine board type... model: 13
> gpio -v => 2.44
A: You need to upgrade to WiringPi 2.46 from 2.44:
> cd /tmp
> wget https://unicorn.drogon.net/wiringpi-2.46-1.deb
> sudo dpkg -i wiringpi-2.46-1.deb>
MPD broken, Volumio isn't playing anything.
> systemctl status mpd -l
Output: /usr/bin/mpd: error while loading shared libraries: libbcm_host.so: cannot open shared object file: No such file or directory
Reason: You upgraded the system with apt-get upgrade.
Solution:
Compile libbcm_host.so from the open-sourced code for the ARM side libraries. To do so:
> git clone https://github.com/raspberrypi/userland.git
Install build-essentials and cmake:
> sudo apt-get install build-essential cmake
Build (will take a couple of minutes):
> cd userland/
> ./buildme
Copy the compiled file to /usr/lib:
> sudo cp ./build/lib/libbcm_host.so /usr/lib/libbcm_host.so
You can now restart mpd:
> sudo service mpd restart
and see if all went well:
> service mpd status
Projektstart: 01. August 2018 um 02:00
Veröffentlicht: 14. September 2021 um 02:00
Letzte Änderung: 24. Oktober 2021 um 02:00