A step by step guide to setup a Bluetooth keyboard and mouse on the Raspberry PI

By ctheroux71 Comments

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
Debian, Linux, Raspberry PI, Wheezy

71 Comments to “A step by step guide to setup a Bluetooth keyboard and mouse on the Raspberry PI”

  1. Al says:

    This works with an Onn bluetooth keyboard from Wal-Mart, which can be bought for around $17.

  2. USB Adapter says:

    TRENDnet’s stream-lined 450Mbps Combined Music group Instant D UNIVERSAL SERIES BUS Adapter, model TEW-684UB, hooks up a laptop computer or maybe computer’s desktop a great ultra-high functionality 450Mbps double band cellular community.
    Discover more: http://www.dueltek.com.au/collections/wireless-adapters

  3. Ricardo says:

    I have a Motorola Xoom Bluetooth Keyboard and I am trying to get this working on a brand new model B+.

    It connects and the hcidump shows the traffic, but nothing happens on the prompt.

    Thanks

    1. Ricardo says:

      Anyone knows if is this a bug?

      Thanks,

  4. JRA says:

    Hello,

    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

    1. ctheroux says:

      Any message in the system log?

  5. zww10250 says:

    This tutorial is clean and simple and the only one about the subject that I could find that is complete and correct.
    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.

  6. Robert L says:

    Hello
    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!!!!!!!!!!

    1. ctheroux says:

      Is your USB port adaptor powered? If not, try removing it. There is a limit on how much power the Raspberry PI can supply. So, plug only a keyboard and the Bluetooth Dongle.

  7. […] If you are using the Bluetooth keyboard and mouse combo, here are some instructions for setup. […]

  8. david says:

    Everything in the instructions works great … until I reboot. Although the bluetooth stack in raspxbmc knows about the bluetooth devices, it doesn’t connect them.

  9. lablansky says:

    Hi!
    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!!!

    1. Thomas says:

      Thomas says:
      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:F7

      where 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

    2. Brandon says:

      When it asks for a PIN on Raspbmc, you type in whatever you want, then hit enter, then immediately type the same thing in on your other device and hit enter as well. They will then be connected. Ignore the dbus error you receive. I got that too and it works without a problem.

  10. guddy says:

    hello.. i want to enable/discoverable the bluetooth dongle with only the power source or usb power hub.. (wall power hub) not computer usb port…
    plzz help me ..

  11. […] found the following guide very helpful, however kept running into […]

  12. Barry says:

    This procedure also worked on a Merkury iPad keyboard.
    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!

  13. Kireb says:

    Worked well with raspbmc on a new pi with the medion bluetooth keyboard and a DBT-120 (http://download1.medion.com/downloads/anleitungen/bda_md86739_ch_%28de_fr_it%29.pdf)

    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.

  14. […] A Step By Step Guide To Setup A Bluetooth Keyboard And Mouse On The Raspberry PI […]

  15. […] in /etc/rc.local. Auch die Umstellung auf eine Bluetooth Tastatur unter Befolgung der Anleitung zur Einrichtung von Bluetooth-Tastaturen brachte keine Besserung. Zwar sind alle Schritte erfolgreich, tippen kann ich jedoch nicht. Ein […]

  16. […] Source: http://www.ctheroux.com/2012/08/a-step-by-step-guide-to-setup-a-bluetooth-keyboard-and-mouse-on-the-… […]

  17. […] L'Antre du Tryphon » Blog Archive » A step by step guide to setup a Bluetooth keyboard and mouse o… […]

  18. Navservice says:

    First and most, thanks for taking the time and trouble to solve this problem and for telling other how to do it, that’s what makes all this work.

    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?

    1. Tujae says:

      I had that problem too. I just continued on to the next steps. Maybe this step had something to do with my current dilemma. I was able to follow all the steps. My keyboard is connected and listed as a trusted device. However, the input isn’t recognized on my device.

  19. sanderbaak says:

    Hello!!, when i use Hcitool scan
    it says
    root@raspbmc:/home/pi# hcitool scan
    Scanning …
    and nothing wil pop up

  20. Claims says:

    And don’t forget to run this to get Atheros dongle working :
    $ sudo apt-get install firmware-atheros

    However, thx a lot for this helpfull how-to ! Keep going !

  21. SteveP says:

    hcitool scan wouldn’t work for me as it couldn’t find a device, even though lsusb showed it was connected.

    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!

  22. [...] my Bluetooth keyboard setup to work on my Raspberry Pi and XBMC, there is an amazing tutorial here that gives all of the steps needed to get Bluetooth working on your RPi. When I ran through the [...]

  23. Tobias says:

    till hcitool scan all ok but then:

    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

  24. dargue says:

    Finally!

    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.

    1. nouman says:

      could you please help me on doing what you did?

  25. Martinscloud says:

    Worked for me, eventually.

    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.

  26. rene says:

    Hi,

    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.

    1. ctheroux says:

      It looks that your keyboard is not paired.

    2. Tujae says:

      I’m having this same problem. The Bluetooth Ipazzport keyboard is connected and trusted, but it doesn’t work. I tried re-pairing it through both the terminal and the Bluetooth manager to no avail.

  27. ctheroux says:

    I have tested this guide on 2013-02-09-wheezy-raspbian for a keyboard (Microsoft) and a mouse (Rocketfish). it works perfectly.

    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.

  28. Vasilis Markou says:

    And something else. Hitting then the command “hcitool scan”, it says that the command is not right (in other words!)
    Thanks again.

  29. Vasilis Markou says:

    Hello and thanks for the nice guide.
    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.

  30. tanimoto says:

    Troubleshoot Mac mini Bluetooth Keyboard Pairing

  31. Lang says:

    when installing the packages, I recommend using the switch –no-install-recommends. Specifically,

    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.

    1. Lang says:

      I meant to say apt will install more with the blues-utils package

  32. steven says:

    How do you access bluetooth manager on raspbmc i have ipaazport bt

    thanks in advance

  33. Ross Austen says:

    Great guide. However I am having troubles at the last gasp.

    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

    1. Mauro says:

      Same thing here I pair ok, insert the code on both and the the apple kb wont work.
      When I connect it does make my apple kb blink but thats all.

      Anyone?

    2. If you are going for finest contents like me, just go to see this web
      page everyday as it presents quality contents, thanks

  34. Max says:

    Hi!
    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!

    1. Nick says:

      I have the exact same error!

      Equally mystified myself. Any help folks?

    2. Chris says:

      I had this problem. It seemed that my keyboard discoverable more had timed out. I made it discoverable again and reentered the connect command and it worked.

    3. xGhOsTkiLLeRc says:

      Make sure the input plugin is enabled in
      /etc/bluetooth/main.conf

      It should not be listed under “DisabledPlugins”

      Cheers

      1. pl0x says:

        And what if it isn’t disabled (that line is commented out) and you still get this error?

    4. Andrew says:

      I received the same string of messages when I tried to enter the “bluez-test-input connect” line too, except my device wasn’t a Smartphone but a Bluetooth earpiece. Instead of the last line being

      ‘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?

      1. Andrew says:

        Talking about interfaces, I just realized that blueman aka Bluetooth Manager is a GUI application. You can see its icon in the taskbar, and in the start menu. I was able to complete the connection to my Smartphone and my headset from there.

  35. adiabatic says:

    In addition to what ArtBIT posted I had to do:

    sudo update-rc.d -f udev defaults

  36. watou says:

    Aside from the (minor) key mapping issue, I am unable to even see (knockoff) Wii remotes when they are in discovery mode during hcitool scan. Does anyone know why they Riiteck keyboard/trackpad worked per this guide, but debian/wheezy (with the standard bluez 4.99-2) won’t even see the Wii remotes?

  37. watou says:

    Thank you so much for sharing this guide. Worked great here with a Riitek RT-MWK02+ and a D-Link DBT-122. But… Some of the keys aren’t mapped properly — for example, the | character comes out as a ~ and the \ comes out as a #. Where is the configuration to properly map all the keys on a given Bluetooth keyboard to their correct functions?

    Again, thanks for sharing this!

    watou

    1. MrScience101 says:

      @watou Sounds like you might need to run raspi-config and select the keyboard layout option. I had to choose a dell, and then us keyboard for it to map correctly.

  38. ArtBIT says:

    I had to enable dbus service in order to complete the installation of the blutooth packages, by running:
    sudo update-rc.d -f dbus defaults

  39. gron says:

    Great guide, thanks a lot! Just got my Logitech Mediaboard Pro working.

  40. wckd Dev says:

    Great instructions! Worked perfectly with the Motorola Xoom Bluetooth Keyboard and Rocksoul Bluetooth Mouse on Pi model b running 12-16-2012 wheezy. Thanks!

  41. andythegrouch says:

    Hi,
    when 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

  42. Alex says:

    I am trying to do this to pair an Exo Ultra keyboard but it fails at the installation of bluez saying that “Service dbus has to be enabled to start service bluetooth”. What am I doing wrong?

  43. Phil Hawkshaw says:

    Hi,

    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!

    1. ctheroux says:

      Your keyboard should be available at boutup. It is for me. Unfortunately, I have no ideas.

    2. Henry Skoglund says:

      Thanks for an excellent walkthru, worked with my El Cheapo ($9.99) Bluetooth keyboard and adapter.

      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

  44. waxtadpole says:

    Thanks for your very precise and helpful instructions from a RPi newbie. I was doing fine trying to connect my iPazzport until I tried to pair the device. For some reason (most likely something I missed) I was not able to enter a passcode. However at this point I switched from the terminal to Bluetooth Manager and was able to pair and activate the input service using the setup wizard. I would recommend that my fellow noobs having trouble try the same.

  45. Brian says:

    Thanks! This worked great with the Ultra eXo mini keyboard/touchpad on my Raspberry Pi model B.

  46. This is fantastic. Thanks a lot. It works with the iPazzPort Bluetooth (Model KP-810-10BTT) and the first revision Pi – like a charm!

    Thanks again!

    1. samuel riley says:

      how would i be able to get an apple wireless keyboard & trackpad working with a raspberry pi B + over bluetooth and what kind of adapter would i need to make it work

      1. ctheroux says:

        Any dongle that uses the Cambridge Radio Bluetooth chip set. I bought mine on eBay. 5 for $8.00. Mine looks like http://www.ebay.ca/itm/Black-NANO-MINI-Thumb-USB-2-0-BLUETOOTH-ADAPTER-DONGLE-EDR-WIRELESS-Plug-/361068333424?pt=US_USB_Bluetooth_Adapters_Dongles&hash=item5411598970 . I cannot certify that they are exactly the same.

Leave your Comment

Your email address will not be published. Required fields are marked *


two + = 10

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Blue Taste Theme created by Jabox