HiFiBerry DAC for the Raspberry Pi

For a long time I've been looking for a way to play music from Spotify on my phone through my home stereo system without having to connect it to the amp directly. There are a couple of reasons for this with the main one being that the DAC (the thing that converts digital music to analogue so that it can be sent out via the headphone jack) in all mobile phones is very poor, not a complaint really as they're designed for headphones and to be small, not suitable for use with a nice amplifier at all.

It's maybe an awkward set of requirements to do on the cheap, there are a few commercial things that do this but the ones with a web interface seem to be outrageously expensive. I had a few old Pis laying around from various other projects that had no use making this my ideal platform on which to build the streaming server.

Luckily there is a piece of software that can act as a streaming server already and another that provides a fancy web interface to Spotify. Installing these was pretty easy as they're both in software repos

wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add -
sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/jessie.list
sudo apt-get update
sudo apt-get install mopidy

for Mopidy and

sudo pip install Mopidy-Mopify

for the Spotify thing. The server needs a bit of config adding to /etc/mopidy/mopidy.conf but it's nothing too scary - here's mine

username = wide_load
password = <snip>
bitrate = 320

enabled = true
debug = false

enabled = true
hostname =
port = 80

The http section is needed as the default it to listen on localhost only and with a weird port.

With all that done it was just a matter of connecting it to the amp and going to the IP address of the Pi in a browser to get something playing. The output from the Pi is significantly better than just the phone, not perfect but very usable depending on the amp and speakers you connect it to.

The fancy part is the addon board that can be stuck on to the Pi via its GPIO pins to act as the sound card. This completely bypasses the average DAC on the Pi to provide its own much nicer one.

In the newer version of Raspbian the HIFiBerry is supported by default, all you need to do is add a line to /boot/config.txt to enable it

# Enable HiFiBerry DAC+

It also needs to be set as the default sound device by creating /etc/asound.conf with

pcm.!default  {
 type hw card 1
ctl.!default {
 type hw card 1

The official instructions say to disable the built in sound card and use a 0 in this file - didn't seem possible to me.

With that done all I had to do was reboot it and replace the 3.5mm jack connector with a phono one and all was good.

The quality is far better, everything sounds much crisper and the lower tones have more depth to them. To be expected I guess although it was a nice surprise as I wasn't expecting to really notice a difference at all and was pretty much just doing this for fun.

Post a new comment