In this tutorial you’ll learn how to set up your Raspberry Pi as a portable and inexpensive Spotify Connect device.
What you’ll need
To complete this tutorial, you’ll need:
Raspberry Pi running Raspbian. If you don’t already have Raspbian, grab the latest version and flash it to an SD card using Etcher.
Power cable that’s compatible with your Raspberry PiExternal keyboard and a way to attach it to your Raspberry PiHDMI or micro HDMI cable, depending on your model of Raspberry PiExternal monitorEthernet cable or connect over Wi-FiRCA-to-headphone cable so you can attach your Raspberry Pi to an audio device such as a speaker or stereo, or a USB audio card for higher-quality audioSubscription to Spotify Premium
Raspbian: Are you running the latest version?
To start, Raspberry Pi should be up and running with the latest version of Raspbian. Boot up your Raspberry Pi and open a Terminal window. Type the following commands: If Raspbian installs any updates, then you’ll need to reboot your Raspberry Pi by clicking the little Raspberry Pi icon in the upper-left corner, then selecting “Shutdown -> Reboot.”
Install the Spotify Client
This tutorial uses Raspotify, a Spotify Connect client specifically designed for Raspberry Pi. Raspotify requires the curl and apt-transport-https packages, so open a Terminal and make sure these packages are installed on your Raspberry Pi: Next, add the Raspotify repository and associated GPG key. The GPG key is particularly important, as it’ll allow the Apt package manager to verify any files it retrieves from the Raspotify repository. In the Terminal, run the following two commands: The Raspotify repository has been successfully added, but currently the package manager doesn’t know about this repository. To keep the package manager in the loop, run the following Terminal command: You can now install raspotify: Raspotify will launch automatically, so you’re ready to start streaming music to your Raspberry Pi!
Enjoy Spotify on your Raspberry Pi
You can now send music to your Raspberry Pi from the Spotify desktop or mobile app. In this section of the tutorial, Spotify for Android is being used, so the steps may differ slightly if you’re using an alternative platform.
- Launch the Spotify app.
- Select the song you want to play.
- Tap the “Devices available” section toward the bottom of the screen.
- In the bottom-left corner, select the little “Devices” icon.
- Find your Raspberry Pi and give it a tap. Your Raspberry Pi should now be playing your chosen song!
Configuring Spotify Connect
To improve the user experience, you can make several changes to the Raspotify software. You can edit Raspotify’s settings by running the following Terminal command: This launches a configuration file in the Nano text editor. You can make various changes to this file including: Give your Raspberry Pi a unique name By default, your Raspberry Pi will have the name “raspotify (raspberry pi).” If you have multiple Raspberry Pis on your network, then you may want to give each device a distinctive name – for example, “Raspberry Pi Kitchen” or “Spotify Connect Client.” To rename your Raspberry Pi, find the following line: And make your desired changes – for example, this tutorial uses: Don’t forget to remove the # symbol! Save your changes using the Ctrl + X keyboard shortcut, then press the y and Enter keys on your keyboard. Every time you make a change to the configuration file, you’ll need to restart your Raspotify service by entering the following command into the Terminal: Check the Spotify application on your smartphone or tablet, and you should notice that your Raspberry Pi now has a brand new name. Boost the audio quality Bitrate refers to the amount of data that’s processed over a certain amount of time. The higher the bitrate, the better the audio quality, while lower bitrates will consume less data which can be useful if you’re playing Spotify on your smartphone. The standard bitrate for Spotify Connect is 160 kbps, but audiophiles can unlock high-quality audio by increasing this value to 320. Alternatively, you may want to experiment with Spotify’s “low-quality” bitrate of 96 to see whether you really can tell the difference. Regardless of whether you’re opting for low-quality (96), medium-quality (160) or high-quality (320), you can control Spotify’s bitrate setting by editing the following line: Save your changes using Ctrl + X, Y and then Enter. Finally, you’ll need to restart the Raspotify service: Ultimately, the sound quality depends on the audio device you attach to your Raspberry Pi. Don’t forget to make use of these Spotify tips to enhance your listening experience.