Home > Arduino, Bluetooth, TKJ Electronics, USB > Bluetooth HID devices now supported by the USB Host library

Bluetooth HID devices now supported by the USB Host library

I am glad to announce that Bluetooth HID devices are now supported by the USB Host library. The library already supports PS3 and Wiimote controllers, but now it also supports more general devices, like Bluetooth keyboard and mice.

An example is available at the following link: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/Bluetooth/BTHID/BTHID.ino.

First time you run the code, you will have to pair with your device, this is done by creating the instance like so:

BTHID bthid(&Btd, PAIR, "0000");

You can of course set the pin to anything you like.

Now you should enable discovery of your device and it should automatically detect any mouse or keyboard present and then connect to them. On Bluetooth mice there is no need to enter any pin, but on a keyboard you should enter the pin on the keyboard and then afterwards press enter.

So in this example you should press 0 four times on the keyboard and then press enter afterwards.

After you have paired with the device, you can simply create the instance like so:

BTHID bthid(&Btd);

When you press any button on your device it will automatically connect to the last paired device i.e. your Arduino.

By default it uses the “Boot Protocol Mode”, but since only basic functionality is available in “Boot Protocol Mode”, I have made it easy to change it.
Simply call this in your setup:


Since it do not read the HID descriptor of your device, you might find that some of the buttons etc. might not work on your device. Unfortunately you will have to modify the parser, but it should not be that difficult.

Simply uncomment:


In BTHID.cpp to see the incoming data and then modify the parser for your needs – the standard parser can be found in hidboot.cpp.

I have currently tested the code with a PS3 keyboard (see image below) and it works perfectly fine, but I had to change it to use “Report Protocol Mode” as described above. A nice thing about the PS3 keyboard is that it features both a keyboard and a mouse, as the keyboard is touch sensitive and can therefore be used as a trackpad.

Furthermore I have tested it with my Apple Wireless Keyboard, Apple Wireless Trackpad and an old Bluetooth mouse from Microsoft that I have and all of them worked fine as well.


This is all for now. Fell free to leave a comment below if you have any questions or problems with a specific device.

Categories: Arduino, Bluetooth, TKJ Electronics, USB Tags:
  1. September 30th, 2015 at 14:01 | #1

    @MartinJ. Brockhus
    Hmm it is properly a conflict somewhere in your code. Can you share it somewhere? Then I will take a look.

Comment pages
1 2 4183
  1. No trackbacks yet.