Tuesday Tooling: Making Bluetooth Connections From The Terminal

Yes this is the late edition of Tuesday Tooling...I've been on holiday

Scenario:

You're connected to your Raspberry Pi / Pocket Chip / Single Board Computer via a terminal session, but you would really like to use a Bluetooth device...no fancy GUI can help us now!

Solution:

Use bluetoothctl

Open up a terminal and enter the following to drop into an interactive bluetoothctl session.

bluetoothctl

Now inside the session lets power on the Bluetooth transceiver in the device.

power on

Turn on the scanner.

scan on

Create a background agent.

agent on

Look for devices that are available for pairing.

devices

You will now see all the devices available for connection, and their MAC addresses.

Find the device that you wish to connect to and copy the MAC address.

Now pair the device.

pair [MAC ADDRESS]

Then trust the device so that we don't have to do this again.

trust [MAC ADDRESS]

Lastly complete the connection.

connect [MAC ADDRESS]

Now you can use your Bluetooth device with you computer!