DEV Community

Recca Tsai
Recca Tsai

Posted on • Originally published at recca0120.github.io

Connect Bluetooth on a Headless Raspberry Pi via CLI

Originally published at recca0120.github.io

When the Raspberry Pi has no desktop environment, pairing Bluetooth devices requires the command line. bluetoothctl handles it.

Steps

Enter the bluetoothctl interactive mode:

sudo bluetoothctl
Enter fullscreen mode Exit fullscreen mode

Enable the agent (used for handling pairing requests):

agent on
default-agent
Enter fullscreen mode Exit fullscreen mode

Start scanning for nearby Bluetooth devices:

scan on
Enter fullscreen mode Exit fullscreen mode

Once the target device appears, note its MAC address, then run pair, trust, and connect in order:

pair xx:xx:xx:xx:xx:xx
trust xx:xx:xx:xx:xx:xx
connect xx:xx:xx:xx:xx:xx
Enter fullscreen mode Exit fullscreen mode

The trust step is important -- once added, the device will automatically reconnect on the next boot without manual pairing.

Top comments (0)