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

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

  1. I made a mistake when pairing, but when I try to repeat the steps it says ‘creating device failed… Already Exists’. What is the command to remove the device and try again?

  2. With minor modifications, this procedure also works for a BeagleBone Black running Debian (still Wheezy as of 28 Nov 2014). One only needs to modify how one becomes root and the procedure works. Add “Cirago Bluetooth 3.0 High Speed & Wi-Fi Combo USB Mini Adapter (BTA7300)” and “Microsoft Bluetooth Notebook Mouse 5000” to the list of devices.

  3. Excellent!

    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.

  4. Thanks alot! after hours of trying to get mine to work I finally did, following this. I’ve one problem though that I can’t figure out. My pi is saying that the device is connected, pared and trusted but for some reason when I type on the keyboard it doesn’t work. Any ideas?

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

  6. 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

      • This fixed it for me:

        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

  7. 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

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

  8. 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.

  9. 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!!!!!!!!!!

    • 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.

  10. 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.

  11. 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!!!

    • 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

    • 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.

  12. 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 ..

  13. 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!

  14. 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.

  15. 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?

    • 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.

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

  17. 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 !

  18. 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!

  19. 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

  20. 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.

  21. 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.

  22. 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.

    • 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.

  23. 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.

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

  25. 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.

  26. 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.

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

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

    thanks in advance

  28. 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

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

  29. 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!

    • I have the exact same error!

      Equally mystified myself. Any help folks?

    • 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.

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

      It should not be listed under “DisabledPlugins”

      Cheers

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

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

      • 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.

  30. In addition to what ArtBIT posted I had to do:

    sudo update-rc.d -f udev defaults

  31. 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?

  32. 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

    • @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.

  33. 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

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

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

  36. 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

  37. 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?

  38. 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!

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

    • 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

  39. 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.

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

  41. 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!

Comments are closed.