Building Spotify Connect audio receiver with Raspberry Pi 3

Tomáš Jecha, MVP, MCSD       27.10.2017       Offtopic, Hardware       26861 zobrazení

I bought analog amplifier Pioneer A-30 for my speakers AQ Tango 85. Only thing this amplifier do is amplifying selected analog signal to connected speakers. You can also buy amplifier with build-in receiver that can receive different types of signals – for example MP3 from USB disk or NAS, internet radio, CDs and much more. My choice was to buy standalone analog amplifier without receiver as I believe that receiver will became obsolete sooner than amplifier because of new protocols and digital formats.

image

I have 4 different inputs connected:

  • sound from TV
  • turntable
  • computer
  • and Raspberry Pi 3 as my primary receiver

image

Raspberry Pi 3 as audio receiver

I am using Raspberry Pi 3 as multi-purpose audio receiver. But there is added value for all hobby developers – you can also use it as web server, video player (HDMI), NAS, home server or as IoT device monitoring temperature at your home or anything you want.

I have prepared guide how to enable Raspberry Pi as Spotify Connect receiver.

SD card image

Download latest Raspbian with desktop image file. Then deploy img file it to the SD card. I used really simple tool Win32 Disk Imager.

Hardware

Raspberry Pi soundcard is not that bad. But I wanted better sound quality so I used HiFiBerry sound card with 192kHz DAC – you can really hear the difference. And it is build specially for RaspberryPi. They also provide nice steel casing which is however bit overpriced. But feel free to use any cheaper casing you want.

There is really nothing complicated about assembling it together:

  • Connect sound card directly to Raspberry Pi main board (no need for soldering)
  • Put it inside casing of your choice
  • Plug in SD card with basic OS image
  • Temporarily connect keyboard and HDMI display to do initial configuration – you can disconnect both later
  • Connect audio cables, ethernet and power supply

image

Configuration

Your device should now boot to Raspbian desktop.

Initial configuration

First we will update system, set up password and enable remote access.

  • Open Terminal console
  • Change default password using command: passwd – default password for pi user is raspberry
  • Run Raspberry configuration utility: sudo raspi-config

image

  • In configuration utility select Update – this updates your system to the latest version
  • In configuration utility select Boot options then Desktop / CLI and check Console (not autologin) – this disables login without password and disables booting to desktop by default
  • In configuration utility select Interfacing options then SSH and check Yes (enabled) – this enables remote access with SSH (make sure you have changed default password before enabling this)
  • Use ip addr command to find current IP address of Raspberry. Pro tip: make reservation of IP address as permanent on your router/server if using DHCP – having same IP address makes it simpler to connect to the device later.

Now you can logout and disconnect keyboard and display if you want. You should be able to remote connect to the device from any computer with any SSH client on default 22 port. I’m using Putty on Windows.

Selecting default sound card

  • List sound cards with command: aplay -l (find number of sound card you want to use – for example “card 1: sndrpihifiberry…”)
  • Edit file /etc/asound.conf (probably not exists yet) to select default sound card – replace number 1 with real card number:
pcm.!default {
    type hw
    card 1
}

ctl.!default {
    type hw
    card 1
}
  • Restart of service or Raspberry is maybe needed, use command: sudo reboot

Installing Spotify Connect client

Spotify Connect is technology that enables your Spotify application (running on phone or computer) to play music on network devices that supports it.

Remark: You need to have Spotify Premium subscription to use Spotify Connect.

I used librespot app with simple installator called Raspotify. Follow these steps:

  • Install Raspotify with: curl -sL https://dtcooper.github.io/raspotify/install.sh | sh
  • Edit configuration file /etc/default/raspotify
  • and Uncommend BITRATE setting line and set high-quality 320 bitrate
  • and name your device (as it will be seen in Spotify)
  • Restart service with: sudo systemctl restart raspotify

Now you should see this device from any Spotify App running in same network.

And you should be able to use it to play music from both mobile application and desktop!

imageimage

image

Nice feature of Spotify Connect is that your Spotify is not required to be running when music is playing. So you can setup your playlist and then turn off your computer and it will keep playing. Unfortunately I found also one downside – implementation doesn’t support repeat and random shuffling function at this moment.

Other options

If you don’t need Spotify Connect or you want other music sources than just Spotify then you can try other more multi-purpose receivers systems:

  • MusicBox – browser based (no need for monitor) system for streaming music from Spotify, SoundCloud, GoogleMusic, local network and lot of others
  • Volumio or Runeaudio – headless based systems (no need for monitor) for streaming music from lot of different sources – looks nice but I haven’t tested any of it
  • OSMC – media center for Raspberry Pi and other platforms that requires monitor and plays music and videos

Components and price

At the time of writing total price was about 3300 CZK. This is full list of components I would use:

 

hodnocení článku

0       Hodnotit mohou jen registrované uživatelé.

 

Nový příspěvek

 

Příspěvky zaslané pod tento článek se neobjeví hned, ale až po schválení administrátorem.

                       
Nadpis:
Antispam: Komu se občas házejí perly?
Příspěvek bude publikován pod identitou   anonym.

Nyní zakládáte pod článkem nové diskusní vlákno.
Pokud chcete reagovat na jiný příspěvek, klikněte na tlačítko "Odpovědět" u některého diskusního příspěvku.

Nyní odpovídáte na příspěvek pod článkem. Nebo chcete raději založit nové vlákno?

 

  • Administrátoři si vyhrazují právo komentáře upravovat či mazat bez udání důvodu.
    Mazány budou zejména komentáře obsahující vulgarity nebo porušující pravidla publikování.
  • Pokud nejste zaregistrováni, Vaše IP adresa bude zveřejněna. Pokud s tímto nesouhlasíte, příspěvek neodesílejte.

Příspěvky zaslané pod tento článek se neobjeví hned, ale až po schválení administrátorem.

přihlásit pomocí externího účtu

přihlásit pomocí jména a hesla

Uživatel:
Heslo:

zapomenuté heslo

 

založit nový uživatelský účet

zaregistrujte se

 
zavřít

Nahlásit spam

Opravdu chcete tento příspěvek nahlásit pro porušování pravidel fóra?

Nahlásit Zrušit

Chyba

zavřít

feedback