This project shows how to connect a Bluetooth speaker to your Raspberry Pi or Pi 400 and offers troubleshooting advice.
Getting Bluetooth speakers to connect and play nicely with Raspberry Pi has not been without its problems in the past with some speakers. Fortunately in December 2020 the Raspberry Pi OS received an important update to smooth the experience with Audio and Bluetooth.
This project will show you how to take advantage of the new features and successfully connect your speakers. If you still have problems, there is advice on troubleshooting.
A UE Boom2 speaker was used in the example but any Bluetooth speaker that conforms to the Advanced Audio Distribution Profile (A2DP) profile should work.
The procedure to connect Bluetooth speakers is different for Raspberry Pi OS Desktop (Full) version and Lite versions.
Since the December 2020 update, Raspberry Pi OS now defaults to using PulseAudio as its audio server. This improves audio management and makes connecting Bluetooth speakers more reliable.
Open a Terminal window and enter the following commands.
sudo apt update sudo apt full-upgrade
sudo apt purge bluealsa
sudo apt install pulseaudio-module-bluetooth
sudo usermod -a -G bluetooth pi
After restart, your system will be ready to connect to Bluetooth audio.
This section applies only to Desktop users.
Your device should be connected and any audio will now be routed to it.
systemctl --user start pulseaudio
If bluetoothctl will not start up check your user has been added to the Bluetooth group – see step 1.
Your Bluetooth speaker should be listed with its 48-bit MAC address.
pair XX:XX:XX:XX:XX:XX trust XX:XX:XX:XX:XX:XX
After a few seconds your speaker should connect and any audio will now be routed to that device.
You can test the speaker by playing a 16 bit Wav format file. These can be found online by performing a search in your favourite search engine.
paplay <wav filename>
You should hear the audio file being played from your speaker!
If your speaker is still silent, make sure the volume is turned up, go back to Terminal and start bluetoothctl.
This will list out all the information about your speaker. The screen below shows that the UE Boom is paired, trusted and connected. If any of these indicate “no” then issue the command again and look for any errors.
If you still have problems then deleting PulseAudio’s temporary directories in Terminal can help:
sudo rm -Rf .config/pulse /tmp/pulse-*
Followed by restarting PulseAudio:
systemctl --user restart pulseaudio
In the past Bluetooth speakers have been difficult to connect to Raspberry Pi but the addition of PulseAudio as the audio server has improved the situation. Hopefully you have been able to follow this guide and successfully connect your Bluetooth speaker.
There are some applications and games that still don’t work with Bluetooth speakers because they directly access the sound system, notably SonicPi.