Bridge Bluetooth keyboard to wired USB. (i.e. Bluetooth HID Proxy Mode). Works like a Logitech Unifying Receiver but for bluetooth devices.
(Image idea from pihidproxy)
NOTE: If you are looking for a project that turns a wired keyboard into a wireless keyboard. This is not the right project. This project does the reverse.
It can be useful in two scenarios:
- You have a bluetooth keyboard, but it doesn't work in BIOS, Bootloader or TV.
- You have a bluetooth keyboard and you want turn it into a programmable keyboard (with TMK USB to USB Converter)
Previously, I used MikerR's pihidproxy but it's not transparency enough and I don't like the start-up time of RPi. So I made this one with Arduino.
- SparkFun Micro Pro 3.3V (Other ATmega32U4 based board should also work)
- USB Host Shield for Arduino Pro Mini (Out of stock due to COVID, I'm using this cheaper clone)
- USB Bluetooth dongle (should supported by USB Host Library 2.0, I've tested this and this)
- a Micro-USB to USB Cable, Soldering Iron Kit, Electronic Wire, Male Header Pin
Follow this guide to connect Micro Pro and USB Host Shield. Or tl;dr:
- Cut the line between VBUS and 2k2 to get 5.0V
- Two Jump wires on VCC and RST, VBUS and RAW
- Put Micro Pro on USB Host shield, align, and connect: (Top) INT, GND, (Bottom) SS, MOSI, MISO, SCK, VCC, GND, RAW
- Open in Arduino IDE
- In
Tools -> Manage Libraries
, search and installUSB Host Shield Library 2.0
,HID-Project
- Let's test if USB Host shield is working:
File -> Examples -> USB Host Shield Library 2.0 -> board_qc
- Upload
Tools -> Serial Monitor
- There'll be a GPIO error, ignore it and send any key in the serial monitor.
- Wait until
All tests passed.
- This article could be helpful if you meet any issue.
git clone https://github.com/houkanshan/arduino-bt-hid-proxy.git
- In
KeyboardParser.h
, comment#define APPLE_MAGIC_KBD
if you're not using Apple Magic Keyboard.
- Upload the project, open
Tools -> Serial Monitor
- Turn on your bluetooth device and start pairing
- Wait for bluetooth scanning
- Follow the guide in the Serial Monitor and finish the pairing
- Now the paired address is remembered by arduino.
The current code will try to re-pair every time after power on. Let's stop it.
- In
BTHID.ino
, commentBTHID bthid(&Btd, PAIR, "0000");
and uncommentBTHID bthid(&Btd);
- Upload
- Press any button on the device, then it should be connected.
- In
Documents/Arduino/libraries/USB_Host_Shield_2.0/settings.h
, change#define ENABLE_UHS_DEBUGGING 0
to1
. It will display detailed log in serial monitor - For more detailed log, uncomment
#define EXTRADEBUG
in*.cpp
file you want to inspect.