Setup: Bluetooth

Setting up Bluetooth for the first time can be a bit of a bear, especially if you want to use a Bluetooth keyboard and mouse.  Since both are critical to getting anything done on the Raspberry Pi it’s important to set them up so they work seamlessly on boot.  Otherwise you may find yourself up a creek with out a mouse and keyboard.

Although the documentation for the Raspberry Pi and Rasbian says that Bluetooth is functional out of the box, I found that I had to install a few things and tinker around with it to get it working.  Going through the GUI seemed intuitively like that would be the easiest way but, again, the command line is really where it’s at.

(Just a side note but setting up Bluetooth on Ubuntu MATE was much easier than Rasbian.)

First step is to install a few Bluetooth packages.

sudo apt install pi-bluetooth bluez bluez-firmware blueman

Set your Bluetooth device to pairing mode and then use bluetoothctl to scan for, trust, pair and connect to your device.

bluetoothctl

Your prompt will change showing that we are now using bluetoothclt.

[bluetooth]#

First scan for the device with the scan on command.

scan on

It will say “Discovery started” and when it finds your device it will show you the device MAC address and name.

[NEW] Device 00:2B:CD:34:55:72 Keyboard

Trust the device with by typing the trust command and then the first two numbers or letters of the MAC address, you can use autocomplete by pressing tab.  Make sure that is the same MAC address as the one just found in the scan and press enter.

trust 00:2B:CD:34:55:72

Then pair and connect to your device, and finally quit out of bluetoothctl.

pair 00:2B:CD:34:55:72

connect 00:2B:CD:34:55:72

quit

There are more commands to use in bluetoothctl and it’s helpful to check them out using the help command.  This way you can unpair devices or troubleshoot if you encounter issues.

bluetoothctl

[bluetooth]# help

 

Advertisements