Howto: Connect Bluetooth devices to Raspberry Pi

Here’s how to connect your Bluetooth devices to your Raspberry Pi. You need a Pi, a Bluetooth dongle and a way to connect to your Pi.

Connect dongle and check if it is recognized:
$ lsusb

Refresh DBus and reboot.
$ update-rc.d -f dbus defaults
$ sudo reboot

Then install all the needed packages.
$ sudo apt-get install bluetooth bluez-utils blueman

Turn on the device you wish to connect and set it to pairing, then start the scanning process to get the MAC address of the device:
$ hctitool dev

Now, you need to have your user account added to the ”bluetooth” group. For this example I use the default ”pi” user:
$ sudo usermod -a -G bluetooth pi

Now it is time to connect (while device still in pairing):
$ bluez-simple-agent hci0 60:C5:47:14:F0:A3

Make sure to set it as trusted:
$ bluez-test-device trusted 60:C5:47:14:F0:A3 yes

Finally connect:
$ bluez-test-input connect 60:C5:47:14:F0:A3

I had difficulties connecting to my Apple Bluetooth Keyboard since it’s on the actually device one has to enter the PIN code, so instead I used Blueman over SSH, which you can get help with here: Howto: X over SSH

After that I ran blueman-manager and paired a device by setup, using a random PIN, and entering it on my keyboard, and pressing Enter. Done.