Bluetooth on Raspberry Pi and embedded systems.

BlueZ5 allows using Bluetooth on Linux for useful tasks like:

  • playing sound from the Linux device over Bluetooth headphones
  • send text with Android phones

This works for Linux computers in general, from laptops to Raspberry Pi or other single board computers with Bluetooth on-board or via USB adapter. BlueZ is very handy for command line Bluetooth on Linux:

apt install bluez5

From any Linux computer with Bluetooth, pair the Bluetooth device from Terminal:

Hardware enable Bluetooth adapter

rfkill unblock bluetooth

start HCI UART service

systemctl start hciuart

Go into Bluetooth interactive mode. Use sudo if “no default controller available” error occurs.

bluetoothctl

shows a list of devices already paired, and goes into an interactive Bluez program.

show Bluetooth adapters usable (there must be at least one).

list

software enable Bluetooth adapter

power on
agent on

Find Bluetooth devices to pair with

scan on

A list of Bluetooth pairing-mode UUIDs stream in continuously. Wait several seconds if you don’t immediately see your device. Be sure the device (e.g. smartphone/laptop) is in visible/pairing mode.

Stop the scan:

scan off

Pair with Bluetooth device, where uuid is your device

pair uuid

trust uuid

Connect to the Bluetooth device:

connect uuid

bluetoothctl commands: from within bluetoothctl interactive prompt.

  • paired-devices: list devices this computer is paired with
  • info UUID: for device with UUID, list capabilities (Bluetooth service profiles).

For example, PANU is PAN user.


Here are several basic Bluetooth commands from the Linux terminal.

List installed Bluetooth devices from Linux:

rfkill list

The listing will look like:

0: phy0 Bluetooth: bluetooth Soft blocked: yes Hard blocked: no


enable Bluetooth devices:

rfkill unblock bluetooth

Which reveals another device:

1: hci0: bluetooth Soft blocked: no Hard blocked: no


List Bluetooth adapter (device) UUID

hcitool dev

Which returns:

hci0

and Bluetooth adapter (device) UUID.


enable Bluetooth

hciconfig hci0 up

BlueZ interactive interface

bluetoothctl

This enables pairing/trusting devices, setup Linux Bluetooth audio, and much more.


Intel Edison Bluetooth user guide manual

Related: