In this Raspberry Pi Spotify tutorial, we will be going through all the steps to set up the Spotify connect service. This setup is headless, so you will need to control it using another device.
Using the Raspotify software package, we can set up your Raspberry Pi so that it can work as a cheap Spotify Connect device.
Working as a Spotify Connect device allows you to easily stream songs from any Spotify app to your Raspberry Pi. This setup is an affordable way of connecting any speakers to Spotify.
In addition to showing you how to install the Spotify connect software, we will walk you through some of the basic configuration options that you can specify.
While this isn’t the full Spotify, it does allow you to easily use any other device to play music from your Raspberry Pi. It also allows you to run Spotify on your Raspberry Pi in a completely headless setup.
You will need a Spotify premium account to be able to complete this tutorial.
Equipment List
Below are all the bits and pieces that I made use of for this Raspberry Pi Spotify tutorial.
Recommended
- Raspberry Pi ( Amazon )
- Micro SD Card ( Amazon )
- Power Supply ( Amazon )
- Ethernet Cable ( Amazon ) or Wi-Fi ( Amazon )
- Spotify Premium ( Spotify )
Optional
This project is all about audio, so it might be worth purchasing a USB Audio Card or a Raspberry Pi sound card. The default Raspberry Pi setup is good enough for most users.
Setting up a Raspberry Pi Spotify Connect Device
1. Our first task is to ensure everything is up to date with our operating system. It will make installing the Spotify software to our Raspberry Pi a little easier.
To do this, we will need to run the following two commands. The first will update the package list. The second command upgrades the installed packages.
sudo apt update
sudo apt upgrade
2. Next, we need to make sure that both “curl” and “apt-transport-https” packages are installed to our Raspberry Pi.
Without these, we won’t be able to set up the raspotify repository on Raspbian.
Run the following command to install our needed packages.
sudo apt install -y apt-transport-https curl
3. With the packages we need installed we can go ahead and add the “raspotify” GPG key and its repository.
Without the GPG key, the apt package manager won’t be able to verify the files it’s retrieving from the repository.
You can do these two things by running the following two commands.
curl -sSL https://dtcooper.github.io/raspotify/key.asc | sudo tee /usr/share/keyrings/raspotify-archive-keyrings.asc >/dev/null
echo 'deb [signed-by=/usr/share/keyrings/raspotify-archive-keyrings.asc] https://dtcooper.github.io/raspotify raspotify main' | sudo tee /etc/apt/sources.list.d/raspotify.list
4. Now that we have the raspotify repository added to our Raspberry Pi, we can now go ahead and install the raspotify package.
This package will handle turning our Raspberry Pi into a Spotify Connect device. We can install the package by running the two commands below.
We need to rerun the update due to us adding the raspotify repository in the previous step. Without an update, the package manager won’t know what’s contained in that repository.
sudo apt update
sudo apt install raspotify
5. With the “raspotify” software now installed, the software should start automatically and be ready for connections.
You should now be able to connect to your Raspberry Pi’s Spotify software. You can do this by opening up the Spotify app on your chosen device and selecting it from the “Connect to a device” menu.
Configuring the Spotify Connect Software
1. While the Raspotify software works perfectly fine right out of the box, you can make changes to its configuration.
You can use this configuration file to adjust things such as the bitrate or the device name.
Run the command below to begin modifying the “raspotify
” config file.
sudo nano /etc/raspotify/conf
2. Within this file, you will see multiple different options that you can configure yourself. We will go into a couple of these and explain what you can use them for.
When changing options within this file, make sure that you remove the hashtag (#
) at the start of the line. Otherwise, the settings will not take effect.
LIBRESPOT_NAME="Librespot"
This option defines the name that Spotify connect service on the Raspberry Pi will use. You can set this to something to easier identify where the Raspberry Pi is or what the Pi is connected to.
By default, Raspotify will set the device name to “raspostify
” followed by the hostname of your device.
LIBRESPOT_BITRATE="160"
With this option, you can specify the bitrate that you would like the device to utilize.
You can pick three different values for this option, 96
for low-quality, 160
for medium-quality or 320
for high-quality audio.
LIBRESPOT_USERNAME=""
If you want to utilize your Spotify account, there are two options in particular that you will need to use.
The first of these options is “LIBRESPOT_USERNAME
“. Within the double quotes, type in the username for your account.
Please note that the username and password options may not be what you use normally to log into the account. You will need to retrieve these details by going to the “Set device password” screen on your Spotify account.
If the link above directs to your profile homepage and there is no option to set a device password, simply enter your normal Spotify Username and password.
LIBRESPOT_PASSWORD=""
The second option you will need to use is the one that allows you to set the password to use to login to your account.
Please type your password between the double quotes on this line before continuing.
When Raspostify connects to Spotify, it will use these credentials, allowing better integration with your account and making the Raspberry Pi easier to be discovered by the software.
3. If you have made any changes, you can save the file by pressing CTRL + X then Y followed by ENTER.
4. Once you have made any changes to the raspotify configuration file, you will need to first restart the “raspotify
” service by running the command below.
sudo systemctl restart raspotify
Hopefully, by now, you will now have successfully set up your headless Raspberry Pi Spotify device. It’s an excellent way to have a barebones audio player that can use any speaker that supports USB or a 3.5mm connection.
There are plenty of other media projects that you can do with the Raspberry Pi. I highly recommend checking out the Kodi media center if you’re after something that can do a little bit of everything.
If you run into trouble following this trouble or have some feedback then please don’t hesitate to leave a comment below.
Thank you for this great tutorial!
One question: does this work with 64 bit OS, too?
Hi Thomas,
I am glad this tutorial has been helpful for you.
Yes, you should be fine following this tutorial on a 64-bit system.
Cheers,
Emmet
Excellent guide! Could you add a note how to install this to older pi1 as that is not supported by new updates?
Hi Tony,
Sorry for the late response. I can add steps but I don’t have a way of verifying they actually work since we no longer have Pi 1’s sitting around.
However, if you are still interested can you please try the following steps.
1. First, download the latest supported version of Raspotify for the Raspberry Pi 1 / Zero V1 by using the following command.
To download this release we will be utilizing the wget command.
2. Once the package has been downloaded to your device you can now install it by using the command below.
You should be able to follow the rest of the tutorial as it is written.
Cheers,
Emmet
works beatuful! thankyou
Hi, I was able to use it few monthes ago on another raspberry,
but now I am not able to install it properly, each step are fine with no error.
But the configuration file do not exist in /etc/default/raspotify,
I install it on Raspbian
Hi Florent,
It looks like a recent update to Raspotify has changed the location of the config file as well as the names of the options themselves.
I have update the tutorial to reflect the changes made so it should all begin to work properly again.
Please let me know if you have anymore issues.
Cheers,
Emmet
This is excellent.
I’m a pi newb, but a linux oldtimer. Just switched to raspberry pi OS from ubuntu 64 after experiencing the wretched wasteland that is ARM64 application development. And to think, I thought I knew everything! Anyway, this tutorial was the first smooth thing for me on a pi, and then so was your plex tutorial. And now I love you. Thank you.
This is exactly what I was looking for to address multiple users in our house needing to interchangeably connect to limited set of speakers. Works seamlessly. Thank you.
Just a hot tip: if you want to use the 3.5mm jack and there is no sound then disconnect the pi from the HDMI cable.
Somehow even if you force the pi to use the jack it still wants to use HDMI.
Works now GREAT! thanks!
Works like A charm with old Raspberry Pi Model B rev 2.0
Hi
I’ve installed it successfully but how to start the raspotify now?
Best regards
Dd
Hi David,
You can start Raspotify by running the following command:
sudo systemctl start raspotify
Thanks! I have this running on 2 model 1 B’s flawlessly. This was exactly what I was looking for. Much appreciated.
Works just perfect on —> Rpi4, now i only need to buy USB sound card !
Thanks ! 🙂
Hi! I’m very excited about this project!!! Thanks so much!!!
But… I’ll love to play that on the mini-jack 3,5 mm.
How can I choose that exit? Or how can I change the hdmi defoult to 3,5mm jack???
Thanks so much!!
Hi again, I’m just fix it, on global adjustments of Raspberry pi Config.
Audio —- “Force jack output”
Thanks so much for the project!!
Work for me ! thank you !
If I put it on a raspberry pi and not I don’t want to run it how to I remove it from the pi?
Hi Tyler,
You can remove the raspotify software from your device by running the following command.
Cheers,
Emmet
Can it be playd over hdmi or is it just usb or 3.5mm jack?
Hi Lars,
This project should work over HDMI.
Cheers,
Emmet
Thanks a lot for the tutorial. I was looking for a Spotify solution for years! Just one question: do you know if it works on a RP 1 model B? Thanks in advance.
Hi Nicolau,
Yes this should still work with a Raspberry Pi 1.
Cheers,
Emmet
Can this download Spotify playlists like on a phone?
Can it play local files (while the local source is available)?
Hi Mwalk,
Sadly not, this is basically just allowing Spotify to stream the audio from the device to the Raspberry Pi.
It will not download, store or play files that are locally available.
Cheers,
Emmet
Works great! Thanks for clear instructions.
Cool, pretty straight forward! Note, that only Spotify Premium users can cast audio on the raspotify device. Otherwise it appears grayed on the Spotify Android app.