Building a Raspberry Pi Audio Receiver CodeX
Building a Raspberry Pi Audio Receiver CodeX
Member-only story
TL;DR
This post shows how to use a Raspberry Pi to build an audio receiver supporting Bluetooth
streaming, AirPlay, Spotify Connect and, UPnP.
I recently wrote another article on this topic, since I wanted to see if meanwhile there
might be another even better solution to building a Raspberry Pi audio receiver. My new
article covers HifiBerryOS a dedicated project for this purpose, that, in my opinion, is
much more advanced than the solution described in the article here. You can find the
article here.
Surely, one could also just buy a streaming device that supports all the technologies
necessary. I already browsed for a well-suited device but didn’t buy it in the end, because
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, CDs, 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.
The setup
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 require a Wi-Fi as well as a Bluetooth dongle to get full
functionality.
Therefore, the first step we do is to insert the microSD card and choose the Raspberry Pi
OS Lite.
Choosing the operating system
Getting a custom Raspberry Pi OS
Choosing 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 in our computer once again and create the files in the “/boot” directory.
WiFi-Setting
The first file is the “wpa_supplicant.conf” in which we define the Wi-Fi configuration for
our Pi and contains the following information:
1 ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
2 update_config=1
3 country=CH
4
5 network={
6 ssid="mywifissid"
7 psk="mypassword"
8 }
/boot/wpa_supplicant.conf
It is important to ensure that we select the correct country, since Wi-Fi settings will be
configured according to it. You can find the correct Alpha-2 code here. Furthermore,
make sure to change the SSID (WiFi-name) and PSK (WiFi-Password) according to your
Wi-Fi.
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.
Basic configuration
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.
1 sudo raspi-config
raspi-config menu
… and “A1 Expand Filesystem” to use the whole space on our microSD card.
Raspi-config: 5 … — L1 Locale
In the list, we then uncheck “en_GB” and check “en_US” and continue.
uncheck en_GB
check en_US
Finally, we add the following export to the “~/.bashrc” file:
1 export LC_ALL=C
We then reboot the pi using “sudo reboot” and update all packages once it is booted again:
Install rpi-audio-receiver
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:
1 cd /home/pi/rpi-audio-receiver-main
2 sudo ./enable-hifiberry.sh
3
4 #follow the instructions
5
6 # enable HiFiBerry
7 Do you want to enable HiFiBerry device tree overlay and ALSA configuration? [y/N] y
8
9 # choose the right dt overlay configuration
10 Which board do you want to enable? [dac/dacplus/dacplusadc/dacplusadcpro/dacplusdsp/digi/digipro/amp] da
The HiFiBerry manual helps to choose the right device tree overlay (dtoverlay)
configuration.
We can now restart our Pi again using “sudo reboot” and are then ready to go.
1 # from https://www.raspberrypi.org/forums/viewtopic.php?t=293406
2 sudo mv /usr/share/piwiz/srprompt.wav /usr/share/piwiz/srprompt.wav.bak
Additionally, we can pick the receiver right from the Spotify app using Spotify Connect.
Moreover, using Apple's AirPlay, we can directly play music on our new Raspberry Pi
audio receiver.
Connect to rpi-audio-receiver using Airplay
Finally, we can also make use of BubbleUPnP to Stream music using UPnP.
Last Words
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. Please 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.