Skip to content

Instantly share code, notes, and snippets.

@lukaszjablonski
Last active August 3, 2026 12:45
Show Gist options
  • Select an option

  • Save lukaszjablonski/b45e783887851d15ed3e199b7886538a to your computer and use it in GitHub Desktop.

Select an option

Save lukaszjablonski/b45e783887851d15ed3e199b7886538a to your computer and use it in GitHub Desktop.
Raspberry Pi Zero 2 W Bluetooth-to-USB HID Bridge

Raspberry Pi Zero 2 W Bluetooth-to-USB HID Bridge

While Bluetooth keyboards are very common and often have a button to switch between multiple devices, I came across two major limitations. First, I sometimes need to access the BIOS/UEFI, which is not possible with a Bluetooth keyboard. Second, I use a single keyboard across three computers, one of which is dual-boot. Because the dual-boot machine acts as two separate devices, I have run out of available slots on my keyboard, which can only switch between three devices.

Motivation

Problem 1: Using Bluetooth keyboard with a multi-boot PC

Problem 2: Accessing BIOS/UEFI with a Bluetooth keyboard

Reasons for the Problems

Problem 1: Bluetooth support is initialized by the OS, not by the firmware (BIOS/UEFI) or bootloader. Each OS maintains its own Bluetooth stack.

Problem 2: Bluetooth pairing is tied to the OS, not the hardware (PC). BIOS/UEFI lacks Bluetooth drivers.

Solution

Both Problems could be addressed by running Bluetooth-to-USB HID Bridge for Raspberry Pi (B2U) on one of the supported Raspberry Pi boards: Zero W, Zero 2 W, 4B, or 5.

Here is how to set it up on the Raspberry Pi Zero 2 W:

  1. Flash "Raspberry Pi OS (64-bit)" to a microSD card using Raspberry Pi Imager.
  2. Insert microSD card to the Raspberry Pi Zero 2 W (Pi).
  3. Plug a USB keyboard and mouse into the Pi's micro USB port labeled "USB" using a USB OTG adapter and/or hub if needed.
  4. Connect a display to the Pi via mini HDMI cable.
  5. Connect the power supply to the Pi's micro USB port labeled "PWR_IN".
  6. Configure the Pi and connect to your Wi-Fi.
  7. Configure remote access via xrdp using Terminal:
    sudo apt update
    sudo apt upgrade
    sudo apt install xrdp
    sudo adduser xrdp ssl-cert
  8. Disable auto-login: Control CenterSystem → Uncheck "Auto-login as current user".
  9. Check hostname (hostname) or IP address (hostname -I) of the PI (note both outputs for later).
  10. Reboot the Pi with sudo reboot or via the GUI.
  11. Unplug the USB keyboard and mouse and disconnect the display (now that remote access is configured).
  12. Access the Pi via Remote Desktop Connection (Windows RDP client). Use noted hostname or IP address as "Computer".

    Optional
    Disable "Authentication is required to refresh the system repositories" pop-up window asking for your credentials after logging in.

    1. Open the Terminal within the RDP session and create a rules file:
      sudo nano /etc/polkit-1/rules.d/46-allow-update-repo.rules
    2. Paste the following configuration:
      /* Allow system refresh without authentication xRDP Session */
      polkit.addRule(function(action, subject) {
          if (action.id == "org.freedesktop.packagekit.system-sources-refresh" &&
              subject.isInGroup("sudo")) {
              return polkit.Result.YES;
          }
      });
    3. Save and close (Ctrl+O, Enter, Ctrl+X)
    4. Restart Polkit:
      sudo systemctl restart polkit

    Reference: https://c-nergy.be/blog/?p=14051#comment-6501

  13. Login to the Pi.
  14. Pair the Bluetooth keyboard via bluetoothctl or simply the GUI Bluetooth manager.

    If Bluetooth does not work

    1. Either try to restart it:
      sudo systemctl restart bluetooth && sudo systemctl enable bluetooth
    2. Or try to unblock it:
      sudo rfkill unblock bluetooth

    Reference: https://forums.raspberrypi.com/viewtopic.php?t=332688

  15. Install the Bluetooth-to-USB bridge:
    sudo apt update && sudo apt install -y git
    sudo git clone https://github.com/quaxalber/bluetooth_2_usb.git /opt/bluetooth_2_usb
    sudo /opt/bluetooth_2_usb/scripts/install.sh
  16. Reboot the Pi with sudo reboot or via the GUI.
  17. Run the smoketest:
    sudo /opt/bluetooth_2_usb/scripts/smoketest.sh
  18. If the test passes, power off the Pi and disconnect the power supply. If it fails, check logs (/var/log/bluetooth_2_usb.log) or re-pair the keyboard.
  19. Connect the Pi to your PC via USB data cable (not power-only) plugged into the Pi’s "USB" port (not "PWR_IN"). The Pi should now act as a USB HID device, forwarding Bluetooth keyboard input to the PC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment