A step by step guide to setup a Bluetooth keyboard and mouse on the Raspberry PI
August 9, 2012
· ctheroux
Linux
Debian
Raspberry PI
Wheezy
A lot of people is having problem setting up a Bluetooth keyboard and mouse on the Raspberry PI. Things get more complicated when your wired keyboard or mouse does not work or prevent your Bluetooth dongle from working. There is hope. This step by step procedure will let you install them or at a minimum let you know what does not work. It uses only the command line interface. It is targeted for the Wheezy Debian distribution.
- First of all, if you already tried to set them up and they do not work, start with a fresh install of the OS. This will rule out anything you have done before that would prevent this procedure from working.
- Plug the Bluetooth dongle directly on the Raspberry PI board.
- Boot the Raspberry PI and connect to it using SSH from another computer if possible. Otherwise, use a wired or wireless keyboard. Logon as pi, password raspberry.
- Switch to root
sudo bash
- Install all the updates. It will take a while.
apt-get update
apt-get upgrade
- Enable dbus
update-rc.d -f dbus defaults
- Reboot
reboot
- Reconnect as described above. Logon as pi, password raspberry. Switch to root.
- Install the required packages. It will take a while.
apt-get install bluetooth bluez-utils blueman
- Reboot and reconnect as described above. Logon as pi, password raspberry. Switch to root
- Make sure that your Bluetooth dongle is recognized. If not, unplug it and re-plug it.
lsusb
- Make your Bluetooth device discoverable. Refer to the device manual.
- Make sure that your device is seen by the Raspberry PI. Take note of its MAC address (ex. 75:EF:82:69:D2:83)
hcitool scan
- Pair the device. When requested, type a pin like 0000 and hit ENTER. If you are pairing a keyboard, type the PIN you have entered and hit ENTER on the keyboard you are pairing. If you are pairing a mouse, you also need to type a PIN of 0000 when requested and hit ENTER. This PIN might depends on the mouse manufacturer.
bluez-simple-agent hci0 75:EF:82:69:D2:83
- Make the device trusted.
bluez-test-device trusted 75:EF:82:69:D2:83 yes
- Connect the device. After a few seconds, your device will be usable.
bluez-test-input connect 75:EF:82:69:D2:83
- Repeat the steps from "Make your Bluetooth device discoverable" if you need to install another device.
- When you will reboot, the devices will reconnected automatically after a few seconds.
This procedure worked for the following devices:
- Cambridge Radio Bluetooth dongle
- Microsoft Bluetooth Mobile Keyboard 6000
- Apple Bluetooth Keyboard (iPad keyboard)
- HipStreet mini bluetooth keyboard
- Merkury iPad keyboard
- RocketFish Bluetooth Mouse
- Razer Orochi Mouse
- iPazzPort Bluetooth (Model KP-810-10BTT)
- Ultra eXo mini keyboard/touchpad
Comments
Leave a Comment
Replying to
Copyright 2012–2026, Claude "Tryphon" Théroux
Thanks a lot, this worked with a plain 20-euro Carrefour Keyboard.
Just had to type the same password on the BT keyboard as the one provided to the bluez-test-input connect command.
Thanks again for sharing this.
Discover more: http://www.dueltek.com.au/collections/wireless-adapters
It connects and the hcidump shows the traffic, but nothing happens on the prompt.
Thanks
Thanks,
sudo nano /usr/bin/bluez-simple-agent
Replace "KeyboardDisplay" with "DisplayYesNo"
You can hit control-W to search for keyboard and replace that string.
control-X
save changes
I also seem to have a problem with the hcitool line.
The device (Riiteck MWK02+) been tested under OSX and Win7 with no problem to recognize it...
I would really appreciate if someone could help me.
root@raspbmc:~# lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
Bus 001 Device 005: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
root@raspbmc:~# hcitool scan
Device is not available: No such device
I have the same problem when following Your instruction. In system log i have noticed "Can't init device hci0: Operation not supported (95)", and I think, that this is the problem
It deserves a lot more attention. I'm going to recommend it wherever I think it is appropriate.
I confirm that the tutorial also works for a Maxxter KB-BT-001 keyboard, which is a really cheap device but it works without a problem.
I have spent the afternoon trying unsuccessfully to setup my RT-MWK02 bluetooth keyboard/mouse. I'm pretty sure that this device is compatible with my Raspberry Pi (running Raspbian OS from NOOBS). I have tried setting this up several different ways and the problem always lies with the hcitool line. Here's the problem....
pi@raspberrypi ~ $ sudo bash
root@raspberrypi:/home/pi# lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 005: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 006: ID 046d:c31c Logitech, Inc. Keyboard K120 for Business
Bus 001 Device 007: ID 046d:c03d Logitech, Inc. M-BT96a Pilot Optical Mouse
(NOTE: Up to this point things seems to be going well. The RazPi sees my dongle (Device #005). Also you will see that I'm using a USB port adaptor to give me more USB ports for my keyboard and mouse BUT the dongle is plugged directly into the RazPi (bottom port))
root@raspberrypi:/home/pi# hcitool scan
Device is not available: No such device
HERE IS MY PROBLEM!!!!
PLEASE HELP ME!!!!!!!!!!
I'll try to keep it short and clear, hoping there is someone out there that knows the answer to my problem...
I am doing this via Putty SSH...
I CAN'T GET the "PAIRING KEY /CODE" for my BT keyboard (MEDION). And it won't respond to entering any key strokes... There is no mentioning of a "default pairing code" in the manual...
In Windows I ussualy get an eight number digit for pairing, but in the RASPBMC case, there is no pairing code listed!?
HCITOOL SCAN recognizes my keyboard, but it's like this:
RequestPinCode (/org/bluez/1034/hci0/dev_90_7F_61_xx_xx_xx)
Enter PIN Code:
...AND THEN no code is listed, no "0000 or 1234" works...
...ALSO...
When I try to enable dbus using the command you showed me, my system responds with:
update-rc.d: using dependency based boot sequencing
update-rc.d: warning: default stop runlevel arguments (0 1 6) do not match dbus Default-Stop values (none)
Help, please! It' s FRUSTRAITING!!!
Your comment is awaiting moderation.
2014/04/20 at 00:33
Hi, Thanks for this guide:
I came across several guides and had the same problem as @lablansky
It’s already a while but since I’ve found the answer here which is in german, so I will just leave the command line, as everything else is described here.
You may look for this:
bluetooth-agent --adapter hci0 1234 00:07:61:F6:97:F7where 1234 will be your pin code (don’t forget to press enter)(and replace the adress)
That helped me, so I hope it works for you as well.
Cheers
plzz help me ..
There's no escape key on that keyboard, which was initially a pain when using XBMC until I discovered that fn + the home button (square circle top left) does the same thing.
Thanks for posting!
lsusb
Bus 001 Device 005: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
I did every step EXCEPT the apt-get upgrade
As for pairing, make sure you turn the device on and press the button on the underside with a pen before using the hcitool scan command.
Pairng took a few tries on the pin step as i might have been too slow. Hence, make sure you enter 0000+ENTER quickly after you did the same on the pi. This is how it should look like:
root@raspbmc:/home/pi# bluez-simple-agent hci0 90:7F:61:xx:xx:xx
RequestPinCode (/org/bluez/1034/hci0/dev_90_7F_61_xx_xx_xx)
Enter PIN Code: 0000
Release
New device (/org/bluez/1034/hci0/dev_90_7F_61_xx_xx_xx)
This is how it looks like when you are too slow:
Creating device failed: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
I'm new to the Raspberry and to Linux but I like to think I follow directions well. When I try to enable dbus using the command you showed me, my system responds with:
update-rc.d: using dependency based boot sequencing
update-rc.d: warning: default stop runlevel arguments (0 1 6) do not match dbus Default-Stop values (none)
Why am I the only one with this problem and what do I do about it?
it says
root@raspbmc:/home/pi# hcitool scan
Scanning ...
and nothing wil pop up
$ sudo apt-get install firmware-atheros
However, thx a lot for this helpfull how-to ! Keep going !
I noticed that there was a reference near the end of the Pi bootup sequence text to a file called frameworkd.conf that was missing from /etc/. Searching for the file with 'sudo find / -iname frameworkd.conf' showed that it was residing in /etc/dbus-1/system.d/. I just copied it over to /etc/ and rebooted.
Now hcitool scan works for me and my mouse and keyboard reconnect on startup. I have managed to login from the command prompt via bluetooth!
raceback (most recent call last):
File "/usr/bin/bluez-simple-agent", line 89, in
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 241, in get_object
follow_name_owner_changes=follow_name_owner_changes)
File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 248, in __init__
self._named_service = conn.activate_name_owner(bus_name)
File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 180, in activate_name_owner
self.start_service_by_name(bus_name)
File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 278, in start_service_by_name
'su', (bus_name, flags)))
File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.bluez was not provided by any .service files
First off, thanks for a great guide. Secondly, in case anyone else out there is struggling with a Cambridge Silicon chipset - 0a12:0001 - I found it was possible to skip the hcitool scan not found problem. I used another device (android phone) to discover the BT address of the Cerulian keyboard I was trying to pair. With the address you can go straight to the bluez- commands.
I too had to execute the dbus command mentioned by Artbit. Also, it wasn't obvious that the the pairing command was waiting for me to enter the pass code - there's no prompt.
I installed and setup the BT-Keyboard (Apple Aluminium keyboard A1314) as described.
The device is connected and Trusted. But if i hit a key, the keyboard-led is shining for a short time but no keystroke is transmitted.
What can I do?
Thanx for your help.
There is many causes if you are having problems. What I recommend, start with a fresh Wheezy installation. Follow exactly the guide.
Power consumption is an issue with the RPI. Even if you have 2 USB ports, plug in it only the Bluetooth dongle, nothing else. If you need to plug anything else, use a powered USB hub. If you power your RPI with a computer USB 2.0 port, you will likely have problems. USB 2.0 port will not supply enough power for the RPI and the Bluetooth dongle. Use an external wallmart adapter that can supply at least 1A.
Thanks again.
I am trying to pair with a bluetooth dongle(ASUS) an apple keyboard. I have done everything to the "lsusb" command as described. The report to the above command says that a bluetooth device is recognized (apparently that is the dongle), and at the same time i have set the keyboard to discoverable mode. But nothing like MAC address is appeared on this step. Any idea what i am doing wrong?
Thanks in advance.
sudo apt-get install bluetooth bluez-utils blueman --no-install-recommends
By default, bluez-utils will also install various other packages for printing and audio which you don't need.
thanks in advance
I can pick up both my bluetooth adapter:
lsusb
Bus 001 Device 005: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
I can see the device I want to pair with:
hcitool scan
00:1F:20:3D:4A:81 Logitech K760
However nothing ever happens to allow me to initiate the pairing.
I am connecting to the pi via SSH over Mac Terminal
Any ideas what I am doing wrong?
Thanks
When I connect it does make my apple kb blink but thats all.
Anyone?
page everyday as it presents quality contents, thanks
I have been following this tutorial and everything seems to work until I try to connect to the device (I am trying to connect with my Samsung Galaxy S2).
When running "bluez-test-input connect 75:EF:82:69:D2:83" (with the correct MAC address, of course), I get:
Traceback (most recent call last):
File "/usr/bin/bluez-test-input", line 40, in
input.Connect()
File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 70, in __call__
return self._proxy_method(*args, **keywords)
File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 145, in __call__
**keywords)
File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "Connect" with signature "" on interface "org.bluez.Input" doesn't exist
Any idea what could be error? I have been trying to google a bit, and it seems to be a problem with dbus, but I can't figure out what to do. Any help would be much appreciated!
Equally mystified myself. Any help folks?
/etc/bluetooth/main.conf
It should not be listed under "DisabledPlugins"
Cheers
'dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method “Connect” with signature “” on interface “org.bluez.Input” doesn’t exist'
It says
'dbus.exceptions.DBusException: org:bluez.Error.NotSupported: Operation is not supported'
For the record, I tried testing a Bluetooth connection with my Samsung Galaxy S4 and the error message I received was exactly the former.
I suspect it could have something to do with the device itself not having the appropriate interface to 'connect' using this method, but I have yet to find some form of confirmation nor a workaround. What do you guys think?
sudo update-rc.d -f udev defaults
Again, thanks for sharing this!
watou
sudo update-rc.d -f dbus defaultswhen issuing the'hcitool scan' I get 'Device is not available: No such device'. The device is trying to associate and the dongle is working. Any ideas
These were the best instructions I've found all week! Thanks!
Managed to get the Apple Keyboard paired however is there a way to make the keyboard available on bootup to type the login details?
Without SSH to the Pi then switching back to the keyboard :-)
I can't login!
Re: how to make your Bluetooth keyboard available when rebooting: look for the Bluetooth icon in the systray, open it and confirm/authorize that your keyboard can connect automatically on reboot. I did and now my keyboard works every time I reboot the Pi.
Rgrds Henry
Thanks again!