RPi Bluetooth keyboard setup

From eLinux.org
Jump to: navigation, search

Hardware setup

This howto was tested on 2012-09-18-wheezy-raspbian.img with a Sitecom CN500 dongle and a Motorola keyboard kit.

Attach the bluetooth dongle to the Raspberry. Leave the keyboard powered off for now.

Install the needed software

Please note that the bluez-compat was not used in this howto.

pi@raspberrypi ~ $ sudo -s
root@raspberrypi:/home/pi# apt-get install bluez python-gobject

check hardware

Check for bluetooth dongles.

root@raspberrypi:/home/pi# hcitool dev
       hci0    00:10:60:A3:5A:AA

Your bluetooth dongle should be visible. Otherwise you should check the driver or the Verified USB Bluetooth adapters page .

scan and pair

Turn on the device in pairing mode.
Scan for devices, you should remember the bluetooth address.

root@raspberrypi:/home/pi# hcitool scan
Scanning ...
       00:0F:F6:82:D1:BB       Motorola Bluetooth Wireless Keyboard

Now pair the keyboard with the pin. This example uses pin 0000.

root@raspberrypi:/home/pi# echo 0000|bluez-simple-agent hci0 00:0F:F6:82:D1:BB
RequestPinCode (/org/bluez/3964/hci0/dev_00_0F_F6_82_D1_BB)
Enter PIN Code: Release
New device (/org/bluez/3964/hci0/dev_00_0F_F6_82_D1_BB)

Trust the device

The Raspberry should trust the keyboard so it connects after every reboot.

root@raspberrypi:/home/pi# bluez-test-device trusted 00:0F:F6:82:D1:BB yes

Test the device as an input

root@raspberrypi:/home/pi# bluez-test-input connect 00:0F:F6:82:D1:BB

After a reboot the keyboard should still connect. It's possibe a keystroke is needed to connect. Connection can take a few seconds.

root@raspberrypi:/home/pi# hcitool con
       < ACL 00:0F:F6:82:D1:BB handle 41 state 1 lm MASTER AUTH ENCRYPT


If the device isn't working the debugging tool hcidump can help.

# apt-get install bluez-hcidump

If the connection is ok but the device does not respond as an input you can check the real vendor and model:

root@raspberrypi:/home/pi# ls /sys/class/bluetooth/hci0\:*/
0005:22B8:093D.0004  address  device  features  input3  power  subsystem  type  uevent

To add an unknown device to udev edit the (non-existing) file /lib/udev/rules.d/62-bluez-hid2hci.rules and append the following line. The method logitech-hid can also be dell or csr.

ACTION=="add", ENV{ID_VENDOR}=="22b8", ENV{ID_MODEL}=="093d" RUN+="/lib/udev/hid2hci --method logitech-hid -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"


The mouse uses the same procedure as the keyboard. Only the bluetooth address changes. To test the mouse on the console you can use the dreaded gpm

 # apt-get install gpm