Building a Raspberry Pi Audio Receiver
This post shows how to use a Raspberry Pi to build an audio receiver supporting Bluetooth streaming, AirPlay, Spotify Connect and, UPnP.
Upgrading your old HiFi system
So many of us still have this old HiFi system, that did cost a fortune back in the time but isn’t used so often anymore since we mostly stream music from Spotify, Soundcloud, Mixcloud, Youtube, and other streaming platforms. What if I told you there is an easy way to give your HiFi system an upgrade by reusing that Raspberry pi which is getting dusty somewhere between your other tech gadgets.
Surely, one could also just buy a streaming device that supports all the technologies necessary. I personally already browsed for a well-suited device but didn’t buy it in the end, cause of the high price or maybe also because I didn’t really know what technology to go for. Since the technology decision is nowadays a commitment to a certain manufacturer or streaming provider. Pretty much as it was years back with Tapes, Vinyl, CD, or MiniDisc (right what the heck is MiniDisc =). Therefore we lock ourselves into the ecosystem of a big company. Using a Raspberry Pi for this purpose can cheaper and also more future proof. We can still use the Pi for something else if we don’t need it as a streaming device anymore.
Awesome sound quality
If you aren’t convinced that the Raspberry Pi is a good fit to stream high-quality music, you are partly right. While the hardware of the Pi is totally capable of handling the music transcoding its line-out connector isn’t really top-notch. I would even say you can play music with it but it does sound terrible. Fortunately, there is an easy solution to this problem using a HiFiBerry hat. HiFiBerry is a manufacturer specialized in producing Audio extensions for the Raspberry Pi. I got myself a HiFiBerry DAC2 Pro which does provide pretty good sound quality and made the music streams sound great on my Pioneer HiFi system from 1978.
The technology behind
To implement a streaming device that supports Bluetooth streaming, AirPlay, Spotify Connect, and UPnP we make use of various different projects.
In this post, I use a Raspberry Pi 4 but a Raspberry Pi 3 should be working as well. Using a Raspberry Pi 2 we also need a WiFi as well as a Bluetooth dongle to get full functionality.
Preparing the microSD card
To set things up we prepare a new microSD card with Raspbian in headless mode. I often use ApplePiBaker to flash microSD cards on my mac. Nevertheless, I did use Raspberry Pi Imager for this manual since some steps are automatically done by ApplePiBaker and I wanted this manual to be as complete and as compatible with Windows and Linux as possible.
Therefore, the first step we do is to insert the microSD card and choose the Raspberry Pi OS Lite.
For this project, we don’t use 64-bit and also no GUI so we can go with the default Lite image the Raspberry Pi Imager gives us.
Once the image is written on the microSD card, we also prepare the network configuration and set configure the headless ssh service. To do so we insert the microSD card to our computer once again and create the files in the “/boot” directory.
The first file is the “wpa_supplicant.conf” in which we define the wifi configuration for our Pi and contains the following information:
It is important to ensure that we select the correct country since WiFi settings will be configured according to it. You can find the correct Alpha-2 code here. Also, make sure to change the SSID (WiFi-name) and PSK (WiFi-Password) according to your WiFi.
Headless SSH access
To automatically activate the SSH server right away we also create a second file under “/boot/ssh”. This file doesn’t need any content but tells the pi to activate the SSH server service.
Once we have created the two files our Pi is ready to start. The next step for us is to figure out the IP address of the Raspberry Pi. This can be accomplished using an IP-Scanner such as fing which can be used on Android, iOS, or on the Desktop. We then connect to the Pi via SSH using the default credentials “pi” (username) and “raspberry” (password). For easier access, we can place our SSH public key into the “~/.ssh/authorized_keys” file.
Once we have access to the Pi we do some basic configuration steps, such as expanding the filesystem, setting the locales, and updating the Pi.
To expand the file system we use the raspi-config menu:
We then choose “6 Advanced Options” …
… and “A1 Expand Filesystem” to use the whole space on our microSD card.
Then we restart the “raspi-config” again and go to the menu “5 Localisation Options”.
Then we choose “L1 Locale”
In the list, we then uncheck “en_GB” and check “en_US” and continue.
Finally, we add the following export to the “~/.bashrc” file:
We then reboot the pi using “sudo reboot” and update all packages once it is booted again:
Installing Raspberry Pi Audio Receiver
Once everything is prepared, we can now install the rpi-audio-receiver using the following commands from the manual on GitHub and follow the instructions from the installation script:
The commands above will install everything without a HiFiBerry DAC hat. If we want to enable the HiFiBerry separately we can still do it afterward using the following commands:
The HiFiBerry manual helps to choose the right device tree overlay (dtoverlay) configuration.
We can no restart our Pi again using “sudo reboot” and are then ready to go.
Troubleshooting the installation
ALAC problem at Shairport Sync installation
Screen Reader Audio Loop
When I first installed a Raspberry Pi audio receiver, I had issues with the screen reader audio message that was played in an endless loop. I found it easiest to apply to the fix from timg236 I found in the Raspberry Pi forum.
Raspberry Pi Audio Receiver in action
We can now connect to our Raspberry Pi as we would do it to any other Bluetooth streaming device or Bluetooth speaker.
Additionally, we can choose the receiver right from the Spotify app using Spotify Connect.
Also, using Apple's AirPlay we can directly play music on our new Raspberry Pi audio receiver.
Finally, we can also make use of BubbleUPnP to Stream music using UPnP.
As we could see converting a Raspberry Pi into a multi-technology streaming device isn’t too complicated. Using a HiFiBerry digital-analog converter we even get high-quality sound. In my opinion, Plexamp could be a nice complement once an updated headless version for the Pi is released. Let me know what you think and if you have other projects, that could be valuable for other readers. If you liked this blog post, make sure to follow me and support my writing. Thanks for reading.
About the author
Remo Höppli is Co-Founder and Software Engineer at Earlybyte.
Earlybyte is an IT consultancy firm specialized in developing new digital solutions for companies around the world from digitalization to IoT solutions, close to the client and its business embracing agility.
Follow me on Twitter to get informed on new blog posts.
Remo Höppli - Co-Founder & Software Engineer - Earlybyte GmbH | LinkedIn
I'm a tech enthusiast working in my own Startup-Up company Earlybyte, which I founded with my study peers from ZHAW…
HiFiBerry DAC2 Pro | HiFiBerry
Compatible with: Raspberry Pi A+/B+/2B/3B/3B+/4B+/Zero This is our HiFiBerry DAC2 Pro with a pair of gold-plated RCA…
A simple, light weight audio receiver with Bluetooth (A2DP), AirPlay, Spotify Connect and UPnP. Devices like phones…
This project is a rebirth of a direct integration between BlueZ and ALSA. Since BlueZ >= 5, the build-in integration…
Shairport Sync is an AirPlay audio player - it plays audio streamed from iTunes, iOS, Apple TV and macOS devices and…
Install the Spotify Connect client on your Raspberry Pi, curl -sL https://dtcooper.github.io/raspotify/install.sh | sh…
I needed a small headless UPnP media renderer for Linux (for small footprint-use in a Raspberry Pi or CuBox), but there…
Snapcast is a multiroom client-server audio player, where all clients are time synchronized with the server to play…
Get the free Fing Desktop for continuous connectivity health checks, advanced speed tests, level 1 troubleshooting…
Configuring Linux 4.x or higher | HiFiBerry
While the drivers for the HiFiBerry boards are already included in the Raspberry Pi Linux kernel. However, to activate…
Apple Lossless Audio Codec with autotools. This repo uses the source code from http://alac.macosforge.org/ and wrap it…
Turning off bootup audio message - Raspberry Pi Forums
I've recently installed Raspberry Pi OS 'buster' on my pi 2. I now find that when I boot up with a USB audio adaptor in…