How to use Bluetooth with Raspberry Pi

In this article, we will learn about the Bluetooth technology and how to use Bluetooth with a Raspberry Pi single board computer.

What is Bluetooth?

Bluetooth is a wireless technology standard that is used for short-distance communication between devices. It was developed initially as a wireless alternative to RS-232 data cables.

There are a lot of devices that are Bluetooth-capable, like mobile phones, tablets, laptops, desktop computers, headsets, and even watches. Bluetooth has become a staple in modern devices that it has become a standard feature on most devices that needs a way to send and receive data wirelessly over short distances.

How does it work?

In simple terms, Bluetooth works by splitting data into packets and sending these packets wirelessly via UHF. The Bluetooth standard uses the frequencies between 2.402 and 2.480 GHz, or 2.400 and 2.4835 GHz.

Bluetooth acts according to a master/slave architecture. One Bluetooth device acts as a master, and it can communicate with up to seven slave devices in a piconet (a small ad-hoc network). The master role of a Bluetooth device can transfer from one device to another, depending on the circumstances. For example, a Bluetooth headset can initially be a master in a network to initiate a connection with a phone. Afterwhich, it acts as a slave, and the phone acts as the master.

Bluetooth in Raspberry Pi

Not all Raspberry Pi models have built-in Bluetooth. The table below summarizes which models have built-in Bluetooth capabilities and which don’t have them.

Model Bluetooth Version
Raspberry Pi 4 Model B 5.0
Raspberry Pi 3 Model A+ 4.2
Raspberry Pi 3 Model B+ 4.2
Raspberry Pi 3 Model B 4.1
Raspberry Pi 2 Model B None
Raspberry Pi 1 Model A+ None
Raspberry Pi 1 Model B+ None
Raspberry Pi Zero W 4.1
Raspberry Pi Zero None

Adding Bluetooth Capability to Raspberry Pi

Adding a Bluetooth dongle is the easiest way if your version of Raspberry Pi doesn’t have built-in Bluetooth or your project needs a higher Bluetooth version.

Remember that not all Bluetooth dongles work with the Raspberry Pi. Please do your own research and verify first if what you are buying will work with the Raspberry Pi model you have. Some compatible Bluetooth dongles are:

  • MIATONE® Wireless Bluetooth CSR 4.0 USB Adapter Dongle
  • TRIXES Raspberry Pi Micro Bluetooth 2.0 Dongle
  • JBtek Raspberry Pi Bluetooth 4.0 USB adapter

How to set up Bluetooth in Raspberry Pi

We can set up and use Bluetooth with Raspberry Pi via the desktop graphical user interface (GUI) or via the command-line interface (CLI).

Via desktop GUI

Setting up Bluetooth via desktop is the easiest way for beginners. To do this, we do the following:

  1. Click the Bluetooth icon on the taskbar.
    bluetooth-icon-on-taskbar
  2. In the sub-menu that appears, select “Add Device…
    bt-icon-add-device
  3. It will now search for discoverable Bluetooth devices available for pairing. Select the device you want to pair and click OK to confirm. You also need to confirm on the other device for the paring to be completed.
    bt-pairing
  4. After successfully pairing, both devices are now connected via Bluetooth interface.

via CLI

  1. Open a new Terminal window.
  2. Type sudo bluetoothctl and press Enter. It will ask for your administrator password. Input it and press Enter.
  3. Type scan on and press Enter. A list of all Bluetooth device addresses will show.
  4. To pair a device, type pair [bluetooth device address].
  5. You will see the message “Pairing Successful” in the terminal window if the connection is successful.

Bluetooth is one of the most common wireless communication that is available in almost all modern devices. I hope this article has given you a basic understanding of how to discover, pair, and connect Bluetooth devices in your Raspberry Pi.