Featured image of post Connect Bluetooth on a Headless Raspberry Pi via CLI

Connect Bluetooth on a Headless Raspberry Pi via CLI

Use bluetoothctl scan, pair, trust, and connect to pair Bluetooth devices on a headless Raspberry Pi without a desktop and auto-reconnect on every reboot.

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

Steps

Enter the bluetoothctl interactive mode:

1
sudo bluetoothctl

Enable the agent (used for handling pairing requests):

1
2
agent on
default-agent

Start scanning for nearby Bluetooth devices:

1
scan on

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

1
2
3
pair xx:xx:xx:xx:xx:xx
trust xx:xx:xx:xx:xx:xx
connect xx:xx:xx:xx:xx:xx

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