How to Set Up Bluetooth on a Raspberry Pi
What you'll need
Posted in these interests:
The Raspberry Pi single-board computer has had built-in Bluetooth connectivity since the release of the Raspberry Pi 3 in 2016, allowing you to connect wireless peripherals such as keyboards, game controllers, headsets, and more to your device.
If you don’t have a model of Raspberry Pi that has Bluetooth built-in, you can use a third-party USB adapter to add support. You may need to install additional software packages to do this, depending on the adapter you use.
If you’re using using Raspberry Pi OS (previously Raspbian), then Bluetooth should be enabled by default, but you’ll need to follow these additional steps to connect and set up your devices.
These instructions will work for Raspberry Pi OS users, including Raspberry Pi OS Lite, which lacks a graphical desktop environment by default.
1 – Installing the Bluetooth manager tool (desktop environment required)
The “full” version of Raspberry Pi OS has a basic Bluetooth settings menu that allows you to enable or disable the service and connect to nearby Bluetooth devices. This is available from the taskbar at the top of your screen.
It’s quite a basic tool, however, and doesn’t allow you to easily control certain types of Bluetooth devices like game controllers or wireless speakers. You can overcome these issues by installing an additional set of packages to manage your Bluetooth settings.
While the additional Bluetooth software packages you’ll install here can be useful for Raspberry Pi OS Lite users, you won’t be able to use the Blueman Bluetooth Manager tool itself, as Lite users don’t have a desktop environment installed. You’ll need to skip to the next section and follow the instructions for setting up Bluetooth using the terminal instead if this is the case.
- To start, open a terminal window by clicking the Terminal icon on your menubar (or press the Raspberry Pi menu > Accessories > Terminal).
- In the open terminal window, type
sudo apt update && sudo apt upgradeto check for new software packages and device firmware updates.
- Once this process has completed, type
sudo apt install bluetooth pi-bluetooth bluez bluemanto install the necessary additional packages.
2 – Using the Blueman Bluetooth Manager tool (desktop environment required)
Once the required Bluetooth software packages have finished installing, restart your Raspberry Pi. Upon rebooting, you should see a second Bluetooth icon with a blue circular background in the top-right corner of your menu bar.
From here, you can begin to control your Bluetooth connectivity and connect with other nearby devices.
- To begin controlling your Bluetooth settings, click this Bluetooth icon on the menu bar. If Bluetooth isn’t already active, click Turn Bluetooth On in the drop-down menu to switch it on.
- Once Bluetooth is active, click the Make Discoverable option. This will allow other Bluetooth-capable devices to find your Raspberry Pi, allowing them to connect.
- With Bluetooth enabled, click the Setup New Device option.
- This will launch the Bluetooth device setup assistant, which will help you to connect with and pair a Bluetooth device. Press Next to begin.
- A list of visible local Bluetooth devices will appear at the next stage. Click the search icon in the bottom-left to scan for any additional devices.
- Once your Bluetooth device appears, select it, then click Next.
- Select the Pair Device option to begin pairing your Bluetooth device, then click Next to proceed.
- If required, click Confirm to authorize the device pairing. You may need to follow similar steps on your Bluetooth device.
- A list of available connection methods will appear at the next stage. Select the appropriate option (for instance, Handsfree to use your Bluetooth device as a handsfree headset for your Pi), then click Next.
- This should complete the pairing and connection process. If it doesn’t, click Close and repeat the steps above.
- Once the pairing process has completed successfully, you’ll be able to view the device (and available services) by clicking the Bluetooth menu icon and selecting the Devices option. From here, you’ll be able to view a list of local Bluetooth devices, as well as devices you’ve paired with — press the Search button to run a new scan for additional devices.
- You can connect to any of these devices manually by right-clicking a device and clicking Pair or Setup to begin the setup process. You can unpair any Bluetooth device by clicking Unpair instead, or Untrust to remove it from your trusted device list.
If your Bluetooth device successfully pairs with your Raspberry Pi, you should be able to control and use it as intended. Additional configuration may be required to use or configure your device, depending on the type of device you’re using.
3 – Setting up Bluetooth using a terminal or SSH connection
If you don’t have a graphical desktop environment installed (for instance, if you’re using Raspberry Pi OS Lite) or if you want to set up Bluetooth remotely over SSH, you can use commands from the terminal to set up your Bluetooth connections.
How to Connect to a Raspberry Pi Remotely via SSH
The preferred (and most common) method of connecting to your Pi to run commands.
You can also follow these instructions if you prefer to use the terminal from the Raspberry Pi desktop environment, or if you’re unable to connect using the Bluetooth Manager tool.
- To start, open a terminal window by clicking the Raspberry Pi menu icon. From there, click Accessories > Terminal to open a new terminal window. If you’re connecting remotely using SSH, connect to your Raspberry Pi using your Pi’s username and password.
- As the default Bluetooth packages are quite basic, you’ll need to install the additional Bluetooth management tools. Type
sudo apt update && sudo apt upgradeto update your Raspberry Pi first. Once this process is complete, type
sudo apt install bluetooth pi-bluetooth bluezto install the necessary additional packages.
- Once these packages have installed, reboot your Raspberry Pi by typing
sudo reboot. You’ll need to re-establish your SSH connection if you’re connecting remotely.
- With a terminal window (or remote SSH connection) open, type
sudo bluetoothctl. You may need to type your username and password again to confirm this. This will launch the Bluetooth terminal configuration tool.
scan onto begin searching for local devices. A list of visible devices will appear, with Bluetooth MAC addresses (the device’s hardware ID) and device names.
- To connect to one of these devices, you’ll need the Bluetooth MAC address for your device. If you see your device in the list, type
pair XX:XX:XX:XX:XX:XX, replacing this string with your device’s Bluetooth MAC address.
- This will begin the pairing process — you may need to confirm this on your device. If instructed, type yes to confirm the Bluetooth passkey is correct.
- If the pairing process is complete, the terminal message will change to reflect the device name, and you may see a pairing successful message.
- Once the pairing process has completed, type
connect XX:XX:XX:XX:XX:XX(using your Bluetooth device’s MAC address) to connect to it. If the connection is complete, a connection successful message (along with other log messages) will appear in the terminal.
- If you want to use this device regularly, type
trust XX:XX:XX:XX:XX:XXto place the device in your Bluetooth trusted devices list. This will save you time, meaning you won’t need to pair it again in the future. If this is successful, a
trust succeededmessage will appear in the terminal.
exitto close the bluetoothctl tool once you’re done.
As with the GUI Bluetooth Manager tool, you may need to follow additional steps to configure and use your device further, depending on the device itself.
4 – Using Bluetooth on your Raspberry Pi
You should (at this point) be able to use your Bluetooth device with your Raspberry Pi. Your Bluetooth devices should be paired, connected, and available for you to use, however you like.
Thanks to the Bluetooth Manager and Bluetooth tools, it’s easy to connect and use multiple Bluetooth devices on your Raspberry Pi. If you’re using an older Pi without built-in Bluetooth, many third-party USB adapters should be supported out of the box, allowing you to connect Bluetooth peripherals with little additional setup required.
There are plenty of Raspberry Pi projects that you can tweak to make full use of Bluetooth connectivity – from wireless speakers to a Raspberry Pi-powered Amazon Echo Furby, where a Bluetooth microphone could be used over a wired alternative. To take it one step further, you can also set up a Raspberry Pi Chromecast!