Although it’s sometimes possible to connect a Raspberry Pi to Bluetooth speakers directly using the Raspbian desktop, this doesn’t always work. This project shows how to connect an Ultimate Ears BOOM Bluetooth speaker to the PI, the same steps should work for most sound devices on the market.
After a few seconds, all the Bluetooth devices nearby will be listed. One of them will be your speaker, you should see a recognisable name and its MAC address. In our case UE Boom 2 as shown below.
pair "YOUR SPEAKER'S MAC ADDRESS"
After a few seconds, the speaker should pair and a message will confirm it was successful. The screen below shows the pair command highlighted, followed by the successful pairing message.
trust "YOUR SPEAKER'S MAC ADDRESS"
connect "YOUR SPEAKER'S MAC ADDRESS"
If the option to select Audio Output doesn’t appear, switch your speaker off and then back on again.
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.
aplay "YOUR WAV FILENAME"
You should hear your sound file being played from your speaker!
If no sound is coming from your speaker, make sure the volume is turned up, go back to Terminal and enter the command below followed by Return
Then enter the following command followed by Return
info "YOUR SPEAKER'S MAC ADDRESS"
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.
Bluetooth devices can be difficult to connect to the PI 4 using the desktop interface as this method doesn’t always work. Using bluetoothctl to pair, trust and connect gives feedback on whether a command was successful and if not, shows some indication as to the problem.
After once having made a successful connection, your speaker should now automatically connect each time you reboot your PI 4.
There are some applications and games that don’t work with Bluetooth speakers at the moment because they directly access the sound system, notably SonicPi.