Make a Spotify Connect Speaker

I love to listen to music as I work, but my old hifi only accepts an RCA auxiliary input. First prize would be a Google Chromecast Audio, but these are no longer available. Next best thing…a Raspberry Pi running Raspotify!

 

In this video I used a Raspberry Pi Model B 2.1 (one of the early models), along with an old 8GB SD card and an old 1A 5V power supply. Unfortunately I didn’t have a USB WiFi module, but I did have an ethernet port.

 

This project is based on this guide from pimylifeup.com:

https://pimylifeup.com/raspberry-pi-spotify/

Step 1

You need to download all software required for this project. All of it is free.


First download the latest version of Raspbian.

https://www.raspberrypi.org/downloads/raspbian/

 

Next get the following tools:

 

Something to load Rasbian onto the SD card.

https://www.balena.io/etcher/

 

Something to SSH into your Raspberry Pi.

https://www.putty.org/

Step 2

When you have all your hardware and software its time to get Raspbian installed installed on your SD card.


Open Etcher and select your Raspbian image (make sure you have unzipped it first). Then select your SD card and once you’ve done that select “Flash”.


This may take some time.

Step 3

Once the image has been written to your SD card you need to create a file called “ssh” in the boot directory of the SD card. This will allow you to ssh into your Raspberry Pi without needing a mouse, keyboard or screen.

The easiest way to do this is to create a text file called ssh, then click View and select  “File name extension”. Then you will be able to delete the .txt extension. (This is how you do it on PC).

Step 4

No its time to move to the Raspberry Pi. Put in the SD card and connect the power. Give it a minute to boot.


Now you need to determine the IP address of your Raspberry Pi. To do this log into your router and look for the device in your device list. Write down the IP address.


Next open PuTTY.

Step 5

Enter the IP address of your Raspberry Pi into PuTTY and click “Open”.

This will take you to the login screen for your Raspberry Pi. The default login details are:


User: pi

Password: raspberry

Step 6

Once you are logged in you are going to want to go ahead and update all the packages already installed on your Raspberry Pi. To do this enter the following command:


sudo apt update


This will check for updates. Once thats done you need to install those updates using this command:


sudo apt upgrade


This may take some time.

Step 7

After the update is done you need to install 2 packages that are required for raspotify. To do this, enter the following command:


sudo apt install -y apt-transport-https curl


Tip: You can copy this command, and then right click in the terminal to paste. This will save you a bunch of typing.

Step 8

With these packages installed you need to install the keys that will allow you to install the raspotify package. This of it like a verification code. Copy paste this commands (you can do it all at once):


curl -sSL https://dtcooper.github.io/raspotify/key.asc | sudo apt-key add -v – echo ‘deb https://dtcooper.github.io/raspotify raspotify main’ | sudo tee /etc/apt/sources.list.d/raspotify.list

Step 9

Now you are just about ready to install raspotify! But first, you need to run one more update:


sudo apt update


And then install raspotify:


sudo apt install raspotify

Step 10

And thats it, raspotify is installed! You should be able to select is from your device list on Spotify!


But…first there are some configuration changes you should make, just so you can personalise your device. We are going to change the name of the sever, and the audio bitrate. To do this we are going to open the raspotify configuration file. Do this with the following command:


sudo nano /etc/default/raspotify

 

Now, scroll down to the line that says DEVICE_NAME=”xxx”. Remove the # from the beginning of the line (the # at the start of the line comments it out) and change xxx to the name you want your device to be called. Then scroll down to the line that says BITRATE=”x”, remove the # and change the x to 320. This is the highest audio quality.

 

Now you can exit buy pressing CTRL + X on your keyboard, and then Y, the ENTER to save changes.

 

Lastly, reset the raspotify server with this command:

 

sudo systemctl restart raspotify

Step 11

And now raspotify is installed and should be ready to go with your custom name!


The last step is optional, and it is where we adjust the volume of the Raspberry Pi analogue output (which is normally quite low). By default, the Raspberry Pi will first try output to HDMI, and if that is not available, it will revert to the 3.5mm jack.


First install these two packages:


sudo apt install alsa-utils


sudo apt install mpg321


The package we have now installed is called amixer, and you can browse the setting available with this command:


sudo amixer controls


You will see a list of the controls available, but the one we are interested in is called ‘PCM Playback Volume’. It should be numid=1.

We will adjust the output volume to 90% with the following command:


sudo amixer cset numid=1 90%

And that is it! You new Spotify Connect speaker is ready to use!

Enjoy!

Materials

A Raspberry Pi (I used a Model 2B)

An SD Card (minimum 8GM)

A 5V PSU for the Raspberry Pi (I used a 1A cellphone charger)

A USB wifi dongle

An auxiliary or HDMI cable to connect to your audio system