Raspberry Pi music server
Jul 13, 2015I’ve recently been spending some time on building an enclosure for my Raspberry Pi-based sound system, replacing the ModMyPi case and micro-USB charger while upgrading the audio quality by using a dedicated DAC.
I started from a nice-looking example I found online, which features an inexpensive aluminum enclosure from eBay and a compact switching power supply to get rid of the external charger.
I used the same aluminum case and power supply as the aforementioned project, but rather than using cables to connect the Pi’s I/O I milled a piece of MDF1 to neatly expose the original connectors, together with the audio jacks and a reset switch:
The reset switch and power rocker are wired to a Mausberry shutdown
circuit. This nifty small device
allows for a clean shut-down, by sending a shutdown signal (over GPIO) to the Pi
when the power button is flipped. A user-space
daemon monitors the GPIO pin,
and issues a halt
command when requested. Finally, when the Pi has shut down
the Mausberry circuit cuts the power, indicated by a LED connected to the Pi’s
VCC
.
Because the case is fully closed (ie. no ventilation holes) I added a DS1820 temperature sensor, wired to one of the remaining GPIO ports. Under normal load the temperature remains at a comfortable 30°C, and even when stressing the system it stays below 35°C.
As a final tweak, I added a 1mF capacitor to the output of the power supply. This turned out to be necessary because of some bouncy switches in my house making the power supply fluctuate by almost 2V, which in turn caused the Pi to reboot. A higher-quality PSU would probably not have had this issue…
Bill of Materials
Item | Price |
---|---|
Total | ~€110 |
Raspberry Pi 2 | €39.95 |
ZJ-B-0905 aluminum enclosure | €8.99 |
Switching PSU (5V 2A 10W) | $5.88 |
Mausberry shutdown circuit | $12.99 |
HiFiBerry DAC+ | €29.90 |
RCA audio jacks | £3.45 |
Strain relief bushing | ~€1 |
Reset button | ~€1 |
microSDHC card (8GB, class 10) | €6.99 |
Software
I initially looked at ready-to-use distributions such as
Volumio (or the related
RuneAudio), but both are just too damn messy behind
the scenes and did not turn out to be reliable enough for general use. Instead,
I decided to configure a generic Raspbian installation. Having wasted enough
time in the past on getting rid of the useless packages provided by the official
Raspbian, I bootstrapped a minimal version using the unattended
netinstaller. The end result
is a minimal Raspbian-based jessie
which boots in 5 seconds (2s kernel + 3s
userspace).
The audio-part is taken care of by Mopidy, a heavyweight but flexible Python-based mpd-like audio server2. To make it all user-friendly, I’m currently using the Mopify web client linked to a premium Spotify account.
Some random notes to close with:
- The HifiBerry DAC+ isn’t detected on the current 3.18.0 kernel in Raspbian
(the HifiBerry test images use 3.18.7), so for the time being you’ll need to
run the horror that is
rpi-update
. - There seems to be a mismatch in volume scale handling between some components used by Mopidy’s alsamixer, so you’ll need to use a software mixer to get useful volume control.
- The
rpi-update
d kernel seems to boot significantly faster than its Raspbian counterpart (presumably because it doesn’t use aninitrd
).
I mean to redo this in aluminum, but didn’t feel like figuring out the milling parameters. That said, it looks reasonably pretty in MDF as well!
[return]Mopidy runs acceptably smooth on a Pi 2, but on the previous generation you’ll experience a sluggish UI and choppy playback of some file formats.
[return]