Streaming audio via Spotify or Airplay to a Bluetooth speaker with Balena Sound
Published on 10 November 2022
Follow-up from the previous post about Spotify on the Raspberry Pi. This makes it work with Airplay or Spotify Connect using balenaSound
Requirements and features
The balenaSound website has very good documentation. You need to install my fork (see below), but other than a newer Spotify library version, everything should work the same.
Install forked version
The vesion of the Spotify library (librespot
) being used by balenaSound is broken. A newer version (0.4.2
) works so I forked a version that works. Issue.
You can use this deploy link to set up an image automatically in Balena.
Or, you'll need to check-out the forked repo (branch: bug/spotify-connect-issue
) and push it to your Balena fleet.
Speaker name
Add the SOUND_DEVICE_NAME
variable to change the name that appears in Spotify and Airplay.
Config changes for Bluetooth speaker streaming
There are two things that need to happen for this to work:
- the Bluetooth speaker needs to pair and connect to the Pi
- balenaSound needs to stream audio to the connected speaker
1. Pairing
I found that balenaSound automatically pairs with my bluetooth speaker every time I turn the speaker on. The Pi needs to be on first, so I leave it plugged in.
If yours doesn't, some comments in this thread have workarounds.
2. Audio output
I managed to get bluetooth audio output working by:
- Turning on the BT speaker and waiting for balenaSound to automatically pair
- Visiting http://192.168.21.108/audio/sinks (or whatever the local IP address is)
- Finding the bluetooth audio sink. Mine was called "
bluez_sink.00_02_3C_6B_63_48.a2dp_sink
" - Add a Device Variable
PULSE_SINK
with the value of the sink namebluez_sink.00_02_3C_6B_63_48.a2dp_sink5
. - Add a Device Variable
SOUND_MODE
with valueSTANDALONE
- After that, Spotify and Airplay stream to the BT speaker.
I was getting errors with the multiroom service, hence switching to the STANDALONE
mode.
Enjoy
The speaker should now appear in the Spotify app as whatever you named it above, or a default name if not. You should be able to play music to it. Turning the speaker on should automatically pair it with the Pi.