Let’s Make Your Raspberry Pi 4 Rock the Party with a Bluetooth Speaker

Connecting a Bluetooth speaker to your Raspberry Pi 4 is an easy task. Follow this step-by-step guide to get your RPi playing music wirelessly. …


Updated October 7, 2023

Need help with your Raspberry Pi?
Contact Me!

Do you love silly Raspberry Pi Projects?
Check out my this YouTube Channel!


Connecting a Bluetooth speaker to your Raspberry Pi 4 is an easy task. Follow this step-by-step guide to get your RPi playing music wirelessly. Are you tired of using wired headphones or speakers and want to experience the freedom of wireless audio? If yes, then connecting a Bluetooth speaker to your Raspberry Pi 4 is the perfect solution for you. In this article, we will guide you through the process of setting up a Bluetooth speaker with your Raspberry Pi 4.

Requirements:

  • Raspberry Pi 4 (any model)
  • Micro USB power supply (2A or more)
  • Bluetooth Speaker compatible with A2DP (Advanced Audio Distribution Profile)
  • HDMI cable and monitor/TV for display (optional but recommended)
  • Ethernet cable or WiFi dongle (for internet connection)
  • SD card preloaded with Raspberry Pi OS (32 GB or higher)
  • Keyboard and mouse (or SSH access to the Pi if you prefer CLI)

Step 1: Prepare Your Raspberry Pi

Before connecting a Bluetooth speaker, make sure your Raspberry Pi 4 is up-to-date with the latest software. Follow these steps:

  1. Connect your Raspberry Pi to an HDMI monitor/TV and power supply (if you haven’t done so already).
  2. Insert the SD card preloaded with Raspberry Pi OS into the Raspberry Pi and boot it up.
  3. Open a terminal window and update the system by running:
sudo apt-get update && sudo apt-get upgrade
  1. Reboot your Raspberry Pi to apply updates:
sudo reboot
  1. Once rebooted, connect to your Raspberry Pi via SSH (if you prefer CLI) or continue with the next step using a keyboard and mouse.

Step 2: Enable Bluetooth on the Raspberry Pi

Next, we need to enable Bluetooth on the Raspberry Pi 4. Follow these steps:

  1. Open the Raspberry Pi Configuration tool by running:
sudo raspi-config
  1. Navigate to “Interfacing Options” and select “Bluetooth”.
  2. Choose “Yes” when prompted to enable Bluetooth.
  3. Exit the configuration tool and reboot your Raspberry Pi by running:
sudo reboot

Step 3: Pair Your Bluetooth Speaker

Now that Bluetooth is enabled, we can pair it with our Raspberry Pi 4. Follow these steps to do so:

  1. Open a terminal window and run the Bluetooth setup tool by entering:
bluetoothctl
  1. Power on your Bluetooth speaker and make sure it’s in pairing mode (check your speaker’s documentation for instructions).
  2. In the bluetoothctl prompt, type:
scan on
  1. Your Bluetooth speaker should appear in a list of nearby devices. Note its MAC address (a unique identifier like XX:XX:XX:XX:XX:XX).
  2. Type:
pair XX:XX:XX:XX:XX:XX

(Replace XX:XX:XX:XX:XX:XX with the actual MAC address of your speaker.) 6. Enter the passkey displayed on your Bluetooth speaker when prompted (usually 00000 or 1234). 7. Once paired, type:

connect XX:XX:XX:XX:XX:XX
  1. You should see a message indicating that the connection was successful. Type exit to exit the bluetoothctl tool.

Step 4: Test Your Bluetooth Speaker

To make sure your Raspberry Pi is outputting audio through your Bluetooth speaker, play a sound file or stream music from a website. For example, you can use the built-in omxplayer:

  1. Install omxplayer by running:
sudo apt-get install omxplayer
  1. Play an audio file with omxplayer:
omxplayer /path/to/your/audiofile.mp3

(Replace /path/to/your/audiofile.mp3 with the actual path to your audio file.)

You should hear sound coming from your Bluetooth speaker. If not, check your speaker’s connection and ensure it’s turned on and paired correctly.

That’s it! You have successfully connected a Bluetooth speaker to your Raspberry Pi 4. Now you can enjoy wireless audio without the hassle of wires or docking stations. Happy tinkering!