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

By ctheroux53 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

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

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

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

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

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

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

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

  7. […] 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 […]

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

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

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

  11. sanderbaak says:

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

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

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

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

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

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

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

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

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

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

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

  22. tanimoto says:

    Troubleshoot Mac mini Bluetooth Keyboard Pairing

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

  24. steven says:

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

    thanks in advance

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

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

  27. adiabatic says:

    In addition to what ArtBIT posted I had to do:

    sudo update-rc.d -f udev defaults

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

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

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

  31. gron says:

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

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

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

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

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

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

  37. Brian says:

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

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

Leave your Comment

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


9 + five =

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