Please select an option to see content specific to your location and shop online.

  • We are still shipping! We are actively monitoring the COVID-19 situation. Thank you for your continued support. We are still shipping! We are actively monitoring the COVID-19 situation. Thank you for your continued support.
  • Free delivery on orders over £60 Free delivery on orders over £60

Project

Set up a Bluetooth Speaker

Use a bluetooth speaker to wirelessly listen to your Pi

Scroll down

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.

1. Get your Pi ready

  • You should start with a switched-on Raspberry Pi connected to mouse, keyboard and monitor, you can learn here how to do it using an Okdo Pi kit
  • Ensure that you have the latest version of Raspbian installed on your Pi. You can learn here how to do it using a micro SD card.

 

2. Scan for devices

  • Switch on your speaker and make sure that no other device is already connected to it. For example, if you usually connect it to your phone, check its Bluetooth settings to make sure it’s disconnected as only one device can connect to the speaker a time
  • Open a Terminal window on your Pi and enter the following command:
bluetoothctl
  • then start a scan with the command:
scan on

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.

Terminal showing bluetooth devices

 

3. Pair your Pi

  • Put your speaker into pairing mode. On the UE Boom there’s a small button that needs to be held down for 3 seconds. Check your speaker’s manual to find out how to do this.
  • Enter the pairing command in Terminal followed by the first few characters of the MAC address found earlier, then press Tab and the rest of the address should be filled in:
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.

Teminal bluetoothpairing.

 

4.Trust

  • Issue the trust command with the MAC address to indicate to the system that the device is trusted:
trust "YOUR SPEAKER'S MAC ADDRESS"

terminal bluetooth trust

 

5. Connect

  • Issue the connect command with the MAC address and wait for the confirmation message
connect "YOUR SPEAKER'S MAC ADDRESS"

 

6. Audio settings

  • Right-click on the Blue Speaker icon at the top right of the Pi’s menu bar, select the Audio Output and select your speaker

If the option to select Audio Output doesn’t appear, switch your speaker off and then back on again.

raspberry pi audio settings

 

7. Testing

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.

  • Open a separate Terminal window by clicking the Terminal icon, change directory to where the sound file is located (Music in our case) by typing the command below followed by Return
cd Music
  • Use the built-in command-line audio player to test that everything works, enter the following command followed by Return
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

bluetoothctl

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.

Teminal bluetooth pairing

 

Summary

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.

Like what you read? Why not show your appreciation by giving some love.

From a quick tap to smashing that love button and show how much you enjoyed this project.