Categories
Technology

Pairing A Bluetooth Keyboard With A Raspberry Pi

Raspberry Pi Logo

This is a step by step guide on how I managed to pair my Bluetooth keyboard (RII ProMini) with the Raspberry Pi. This might help people who are struggling with it just as I was.

  1. First of all, start with a fresh install of NOOBS on your Raspberry Pi and install Raspbian. This will rule out anything you have done before that would prevent this guide from working.
  2. The Bluetooth installation was not working with me when I was using the latest NOOBS build so I went with a build before December 8th 2013 (November 4th 2013 build). I have noticed on several different forums that the latest build of NOOBS is using a kernel that is stopping most, if not all, Bluetooth dongles from working. I am not sure how true that is since I am not a Linux expert. But I can say that my Bluetooth keyboard worked with a older build of NOOBS and not with the latest build.

  3. Plug the Bluetooth dongle directly on the Raspberry PI board.
  4. Boot the Raspberry PI and connect to it using SSH from another computer.
  5. All you need is an SSH client like PuTTY, the IP address of your Raspberry and your login credentials. I would not recommend using a wired keyboard since my installation would not work when I was using one. This could have just been a one-off situationso it might not happen to you. Just do not say that I did not warn you.

  6. Switch to root.
  7. sudo -s

  8. Install all the updates. This will take a while.
  9. apt-get update

    apt-get upgrade

  10. Enable dbus
  11. update-rc.d -f dbus defaults

    Don’t worry if this gives you an error as I got one as well. Just continue with the rest of the guide.

  12. Reboot
  13. reboot

  14. Reconnect to your Raspberry Pi as described in the earlier steps (login and then switch to root).
  15. Install the Bluetooth dependency files.
  16. apt-get install bluez python-gobject

    apt-get install bluetooth bluez-utils blueman

    I did both commands because my Bluetooth was still not working after I did the first command only. Not sure if I got the wrong dependency files or that if Bluetooth only works by doing both commands. If you are following my guide I would recommend doing both commands.

  17. Reboot
  18. reboot

  19. Reconnect to your Raspberry Pi as described in the earlier steps (login and then switch to root).
  20. Check that your Bluetooth dongle is recognized. If not, unplug it and re-plug it into the Raspberry Pi.
  21. lsusb

  22. Make sure your Bluetooth device is set in discoverable mode and scan for the device using Raspberry Pi. Make note of the keyboard’s MAC address (e.g. 01:23:45:67:89:AB)
  23. hcitool scan

  24. Pair the device. When requested, type a pin like 1234 and hit ENTER. Then type the same PIN and hit ENTER on the keyboard you are pairing with.
  25. bluez-simple-agent hci0 01:23:45:67:89:AB

  26. Make the keyboard a trusted device
  27. bluez-test-device trusted 01:23:45:67:89:AB yes

  28. Connect to the keyboard.
  29. bluez-test-input connect 01:23:45:67:89:AB yes

  30. When you reboot your Raspberry Pi, it will take a few seconds for the keyboard to become usable.

These are the steps I took to pair my keyboard. I could explain what is happening at each step but I think the post will end up being too long. I hope this guide will help you.

Note: This method worked at the time of writing this post. If you still need help then consider leaving a comment or contacting me via Twitter.

2 replies on “Pairing A Bluetooth Keyboard With A Raspberry Pi”

Leave a Reply

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