Listen to Spotify Connect, Bluetooth, and AirPlay with a Raspberry Pi Receiver

by | Jan 7, 2019 | Audiophile, Technology

A great way to use the Raspberry Pi is to use it for an audio receiver. Setup with your Stereo will allow a whole new world of possibilities. Using Spotify Connect (Premium required) you can stream in music all day without needing audio pushed from another device. With Bluetooth connectivity, you can connect your smart devices like Alexa, Google Home, or Mycroft. And with Apple Airplay and UPnP you pretty much have all the bases covered for listening to anything through your stereo.

If your using a Raspberry Pi 3 or older, you will need a Bluetooth dongle. The Raspberry Pi 3 does have integrated Bluetooth, but there is a known issue where WiFi and Bluetooth usage at the same time causes interference. Bluetooth dongles like this are cheap and work well.

This guide will show you how to configure usage with a DAC as the Raspberry Pi doesn’t have the cleanest audio output. This is optional however, you don’t need to configure it if you don’t have one. I am using a Cambridge Audio DacMagic, but there are certainly cheaper alternatives that work great as well.

Lets install Raspian Lite

Lets grab the latest release version of Raspian Lite from here.

Once downloaded, write the image to your SD card. If your new to writing images, there is a great cross-platform program called Etcher you can use to write to the SD card. It can be found here.

Once your have written to the SD card, lets insert and start our Raspberry Pi.

Configure Raspian Lite

On first boot, we will need to do some initial configuration on the Raspberry Pi. First we need to log into the system with the following.

User: pi
Pass: raspberry

This will log us in with the default user/pass. Now at the command prompt, enter the following.

[sourcecode language=”shell”]sudo raspi-config[/sourcecode]

Change your default password. (You may want to set your keyboard layout first under localization options)
Configure your network options.
Configure your Localization settings.
Under Interfacing Options, set SSH to be active.

Once complete, select Finish to reboot the system.

Once restarted, lets now login to our Raspberry Pi again using SSH or the console again with

User: pi
Pass: (new password)

Now lets see if there are any updates for Raspian using the following commands.

[sourcecode language=”shell”]sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo reboot[/sourcecode]

If your using a Bluetooth Dongle

Lets disable the onboard Bluetooth so we don’t run into any conflicts.

[sourcecode language=”shell”]sudo nano /boot/config.txt[/sourcecode]

Now scroll to the bottom of the file, and add the following to the end of the file.

[sourcecode language=”shell”]# Disable onboard Bluetooth

Press Ctrl+x, press y to save the changes, and enter to exit the editor.

Now at the prompt, enter the following command.

[sourcecode language=”shell”]sudo systemctl disable hciuart.service[/sourcecode]

Lets Configure the Raspberry Pi to use our DAC

If your using a USB DAC, we will need to configure the Raspberry Pi to use the USB connection by default when rebooted. To do this, we need to reconfigure the order it uses for audio devices. Lets create a new config file with the following command.

[sourcecode language=”shell”]sudo nano /etc/modprobe.d/alsa-base.conf[/sourcecode]

Now in the new window, lets name and reorder our audio devices. Enter the following in our new file.

[sourcecode language=”shell”]# sets the index value of the cards but doesn’t reorder.
options snd_usb_audio index=0
options snd_bcm2835 index=1
# does the reordering.
options snd slots=snd_usb_audio,snd_bcm2835[/sourcecode]

Press Ctrl+x, press y to save the changes, and enter to exit the editor. Now, on reboot, our Raspberry Pi should default to the usb audio device. Lets give a quick reboot to save our new configuration files.

[sourcecode language=”shell”]sudo reboot[/sourcecode]

Now lets setup our Audio Hub

First, lets name our Raspberry Pi to something meaningful for us to connect to. I am going to use the name Stereo. This will be the name that shows up when you are searching for the Raspberry Pi to connect to.

[sourcecode language=”shell”]sudo raspi-config nonint do_hostname stereo
sudo hostnamectl set-hostname –pretty "Stereo"[/sourcecode]

GitHub user nicokaiser has done a great job of creating a great set of scripts that automates much of the setup for us.

[sourcecode language=”shell”]sudo apt-get install git -y
git clone
cd rpi-audio-receiver[/sourcecode]

Lets setup the Bluetooth receiver. This will make the raspberry pi discoverable any time there isn’t an active connection and allow A2DP streaming.

[sourcecode language=”shell”]sudo ./[/sourcecode]

Next lets setup our shairport receiver. This will allow audio input using Apples Airplay protocols.

[sourcecode language=”shell”]sudo ./[/sourcecode]

Next lets set up Spotify Connect. This will allow you to use the Raspberry Pi as a Spotify Connect Device.

[sourcecode language=”shell”]sudo ./[/sourcecode]

Lastly, lets configure UPnP so that UPnP devices can also use our new audio hub.

[sourcecode language=”shell”]sudo ./[/sourcecode]

Some final configuration

Now lets adjust our output volume with the following command.

[sourcecode language=”shell”]sudo alsamixer[/sourcecode]

Turn your default volume level up to anywhere from 85% to 100% and press ESC. Now we need to store this volume level for any time we reboot.

[sourcecode language=”shell”]sudo alsactl store[/sourcecode]

Next, lets start up our Bluetooth. Enter the following commands.

[sourcecode language=”shell”]sudo bluetoothctl
power on
discoverable on

Lets give our system one final reboot to make sure everything is live.

[sourcecode language=”shell”]sudo reboot[/sourcecode]

All finished!

After our Raspberry Pi reboots, we should be able to have it stream in Spotify using Spotify Connect, pair it using Bluetooth, or stream directly to it via Apple AirPlay or UPnP! Thanks again to nicokaiser for taking the headache out of configuring everything separately.

If you found this guide helpful please leave me some encouragement below! If your really happy, you can always gift me a coffee, I can never say no to coffee!

I have also by request added a bitcoin donation address. If you want to show your appreciation I would be grateful, but under no means do you need to feel obligated. This is a fun hobby for me. 🙂

BTC: 1GzagpXcAkELhU5emJFMLZpp7J5ayfcNQF

And for those that have, thank you for enabling my coffee addiction! You all know who you are!