Detailed instructions for setting up a Raspberry Pi Zero W as a Bluetooth-enabled music player for the Logitech Media Server streaming system.
I'm a long term user of Logitech's Squeezebox music server system. Despite Logitech discontinuing their line of Squeezebox players several years ago, the system seems to carry on in rude health owing to the dedication of a number of software contributors, and the excellent community support forums. One significant factor in the system's survival has been the development of piCorePlayer, an operating system based on TinyCore Linux for the Raspberry Pi (more information here). Since its initial launch, piCorePlayer has become astonishingly refined, even allowing installation of LMS (Logitech Media Server). Indeed, my home music system uses a Raspberry Pi model 3 as its server.
PiCorePlayer has a number of advantages over some other Pi-based systems. On boot, it loads into RAM and once loaded doesn't write to the Pi's SD card - to switch the Pi off, you just turn off the power. PiCorePlayer itself is hugely versatile, and supports a wide range of Raspberry Pi expansion cards, including DACs and amplifiers, supports the official 7" touchscreen, and also bluetooth connections to speaker/headphones.
Generally, such players are set up headless, and any command line tinkering is done via an ssh connection. Almost all administration and set up of piCorePlayer is done through a web interface. Because piCorePlayer runs in RAM, changes made through the web interface need to be saved and the Pi rebooted to implement the changes. In the instructions below, I haven't always noted when reboots are necessary - the web interface will tell you!
The Raspberry Pi Zero is startlingly small, even compared with the Raspberry Pi models 1, 2 and 3. It doesn't have an ethernet port, though it does have two micro-USB ports (one is only for power) and a micro-HDMI port. Connectivity is therefore quite limited, and because there's no ethernet port, setting it up with piCorePlayer headless on a network is a little different from my previous experience with its larger Raspberry Pi brethren.
The object of this exercise was to put together a budget Bluetooth music streamer, pulling music via an LMS music system. In the current example, I am using the piZero to stream music from an LMS installed on a WD hard drive which carries a copy of my music collection, and which I use when travelling.
Parts:
Raspberry Pi Zero W, 16Gb microSD card and adapter, case, USB power supply. All bar the power supply came in a reasonably cheap kit via Amazon, also featuring a couple of USB and HDMI adapters and a heatsink. I fitted the heatsink, though I don't know if it's really necessary. The microSD card cam with one of the Raspbian distros.
Software:
piCorePlayer 4.0.0. I tried 4.1.0, but I couldn't get Squeezelite to start with bluetooth enabled. This may be an issue specific to my Bluetooth hardware, a pair of Bowers & Wilkins PX headphones.
Setting Up
Unzip the piCorePlayer 4.0.0 image and flash it to the microSD card. I use Apple-Pi Baker, an app for Macs, but there are options available for most operating systems. Don't eject the card just yet.
Follow the instructions for setting up WiFi - I used the option of editing the wpa_supplicant.conf file, which is pretty straightforward. Look for this section that needs to be edited.
network={
ssid="XXXX"
psk="YYYY"
key_mgmt=WPA-PSK
auth_alg=OPEN
}
XXX and YYYY are where you type the SSID and password for your WiFi network (the same one as your LMS will be connected to). Keep the quotation marks!
Just save the file to the boot partition of the SD card. Then eject the card and insert it into the piZero.
Boot the piZero by plugging in a standard USB power supply. In a few seconds, it should appear on your router's list of attached devices (other methods of identifying the piZero's IP address are here). It's convenient to allocate it a fixed IP address on your network. If your piZero doesn't connect to your network, check you've entered the SSID and password correctly in wpa_supplicant.conf)
Open the piCorePlayer's web interface by entering the IP address in your browser. From here, things are pretty straightforward, though a few reboots are necessary - follow the on-screen instructions in this regard. I haven't changed any Squeezelite or audio settings other than as noted here. The screen shots below are taken from the final setup of the player, so you can see I've renamed the player from "piCorePlayer" to "DeepThought".
The piCorePlayer web interface is well laid out and pretty intuitive. Many of the options have help and tips associated with them (click the more> link against each option), and when a reboot is required, this is prompted. Generally, items active are indicated by a green tick symbol, those not active by a red cross symbol. There are several points where a selection needs to be saved by clicking a "Save button". This is important because piCorePlayer is loaded to RAM and changes won't persist until saved.
First off, select the Beta tab at the bottom of the pCP screen. Several steps here require this.
Open the Main Page section. Expand the filesystem so it's large enough to install extensions. This only takes a few minutes after clicking the "Resize FS" button. Follow the instructions that then appear.
Open the WiFi Settings section and turn Bluetooth on. Click "Save".
Open the Squeezelite Settings section. It should have Analogue output selected as default, and Squeezelite should be running (indicated in green at the bottom of the web page - see the screenshots). Under Audio output device settings, choose Bluetooth Audio from the dropdown list and click Save. Squeezelite should stop running at this point and the Squeezelite descriptor at the bottom of the page will change from green to red.
Click the Card Control button. The Bluetooth Connect Daemon isn't installed by default, so this needs to be installed. Click the button to install Bluetooth.
Make sure the Connect Daemon is running (green tick), then pair the BT device you're using. To do this, click "Scan". When the scan is complete, you should see your BT device listed in the drop down list next to the "Pair" button - select it and click "Pair".
I found that it took two or three attempts to pair my headphones, but they did pair. Shortly after, Squeezelite should start up, and the piCorePlayer should appear as a player in your LMS web interface.
There are active discussions about Squeezebox, LMS and piCorePlayer at the Squeezebox forums. Most of the piCorePlayer discussion is found in the Linux/Unix subforum there. The piCorePlayer website has a growing set of instructions.