In the article RaspberryPi – Install “Shairport” Airplay-server on the RaspberryPi, I described how you can easily expand your RaspberryPi with the function of an AirPlay speaker.
Thanks to another cool open source project, it is also possible to use your RaspberryPi as a Spotify speaker. All you need is a connected speaker, the appropriate software and a Spotify Premium account.
Everything you need is described in the following article.
- 1 Safety instructions
- 2 Affiliate links / advertising links
- 3 Requirements
- 4 Log in via SSH on the RaspberryPi
- 5 Set up the paketlist
- 6 Install Raspotify
- 7 Checking the status of raspotify
- 8 Set up autostart
- 9 Start playback on the phone
- 10 Modify configuration of raspotify
- 11 Restart Raspotify
I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂
Before you start with this article, you should have prepared the RaspberryPi so that it can be reached via the network and controlled via SSH.
The following three articles describe what needs to be done to prepare the RaspberryPi:
RaspberryPi – Setup for nerdiys!
RaspberryPi – The first configuration!
RaspberryPi – Control the RaspberryPi via SSH
– none –
Log in via SSH on the RaspberryPi
To get started, you first need to log in to RasPi with SSH on Putty. How to do it is described in the article
Set up the paketlist
First you have to prepare the package source of your RaspberryPi.
Install the two packages “transport-https” and “curl” by entering the following command.
sudo apt install -y apt-transport-https curl
Now you first have to add the GPG key of the raspotify repository. Enter the following command to do this.
curl -sSL https://dtcooper.github.io/raspotify/key.asc | sudo apt-key add -v –
Once you’ve done this, you can add the actual repository to the package list. To do this, enter the following command.
echo ‘deb https://dtcooper.github.io/raspotify raspotify main’ | sudo tee /etc/apt/sources.list.d/raspotify.list
So that the contents of the now updated package list can be collected, you now have to enter the following command.
sudo apt update
If this command has “run through” your package list is updated and “Raspotify” is ready for installation.
It continues in the next paragraph. 🙂
The actual installation of “Raspotify” is done quickly thanks to the prepared package list.
To start the installation, simply enter the following command into the console of your RaspberryPi.
sudo apt install -y raspotify
The installation should then run automatically.
To start “Raspotify”, just enter the following command.
sudo systemctl start raspotify
Checking the status of raspotify
You can then use the command line tool “systemctl” to check whether the start of “Raspotify” worked.
To display the status of “Raspotify”, it is sufficient to enter the following command.
sudo systemctl status raspotify
Here you can see now whether “Raspotify” has started or, for example, could not be started.
Set up autostart
So that “Raspotify” starts automatically after restarting your RaspberryPis, you should now activate the autostart.
Enter the following command into the console of your RaspberryPi.
sudo systemctl enable raspotify
Start playback on the phone
Now you can already start a first test, because you should be able to use it without further changes to the configuration of “Raspotify”. Further setting options for the Raspotify configuration can be found in the next section.
To do this, open (for example) your Spotify app on your mobile phone and click on the highlighted symbol in the playback view.
Your RaspberryPi should now be listed in the displayed list. As soon as you have selected this, the audio output from Spotify should be redirected to your Raspotify speaker.
Modify configuration of raspotify
In the “Raspotify” configuration file you can edit various settings such as the name of your Raspotify loudspeaker.
To do this, open the Raspotify configuration file by entering the following command.
sudo nano /etc/default/raspotify
In the file you will find various configuration options. The corresponding description for each option can be found in the associated comment.
Among other things, you can also set the name of your Raspotify speaker here.
Simply change the parameter for “DEVICE_NAME” to your desired name.
After changing the configuration file, you have to restart Raspotify for the changes to take effect.
You can restart Raspotify by entering the following command.
sudo systemctl restart raspotify
I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂
P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂