8 ms·
Show HN: Bluetooth USB Peripheral Relay – Bridge Bluetooth Devices to USB
Hi HN! I built Bluetooth USB Peripheral Relay, a tool that lets Bluetooth devices (like keyboards and mice) connect to USB-only hosts using a Raspberry Pi Zero W.
Why? My friend needed a way to use his Bluetooth mouse and keyboard on a PC with Bluetooth disabled due to policy restrictions. This tool acts as a bridge, relaying Bluetooth input over USB. It also lets you use Bluetooth peripherals with older devices that only support USB input.
Tech: Written in Go, optimized for Raspberry Pi Zero W.
I love HN’s community and often lurk here—I’m hoping this project is useful or at least sparks some interesting discussions. Feedback and contributions are welcome!
- AshamedCaptain 2y agoI just miss the dual mode HID/HCI bluetooth adapters.
- deleted 2y ago[deleted]
- Bjartr 2y agoWhat could those do special?
- AshamedCaptain 2y agoExactly the same as what this device is doing, plus more. You would put it in HCI mode, pair whichever Bluetooth devices you wanted to pair with it (keyboards, mice, etc.). Then on the next reboot it would put itself back into HID mode, where all the paired devices would appear as USB HID devices. And therefore your keyboard would be available even during pre-boot, at the BIOS setup program. Once the operating system finished loading, it would send the adapter the command to switch to HCI mode, and the adapter would then re-appear as a normal bluetooth adapter. Under BlueZ, this operation was done by a command called hid2hci. I have several (even Apple used to do this), but they stopped being a thing during the 2.0 EDR era (therefore zero support for LE keyboards). In fact, if you google these keywords ("HID proxy", "HID2HCI", ...) you will find that there are several much older projects to also replicate this using RPi Zeros. I personally would like one which extends the concept to audio devices, serial ports, etc. so that I can use them from OSes without BT stack.
- naoru 2y ago[flagged]
- deleted 2y ago[deleted]
- tiernano 2y agoThis is brilliant! It just shows what can be done with the raspberry pi and other small computers, and some time! I love seeing stuff like this and the like. BlueSCSI is another example. If you think outside the box, the pi can act as a DPU, to an extent, for machines. It can already act as a KVM… and the PiKVM project has the option of mounting storage to the host, and even networking. Very cool stuff!
- bahaaador 2y agoThank you for the kind words, I'm glad you're finding it interesting! ^^
- anonym29 2y agoCool project! Out of curiosity, do you think this concept could be extended to other common bluetooth use cases, such as wireless headphones/speakers, or file transfers over bluetooth to mobile devices, or are the audio/file transfer/etc stacks too far removed from the HID stack for that to cleanly translate?
- bahaaador 2y agoThank you! Great question. I can see this being fairly easily extendable to other HID devices and even modifying their behaviour slightly (e.g. remapping a key) but audio stack sounds like (no pun intended) a different beast altogether. A buddy of mine had a similar question around connecting his BT gamepad and headset to play PS games on PC so I'll be looking into this more.
- waiquoo 2y agoThis is awesome! I have some serial devices (RS 232) that I've wished I could make wireless. Are there any similar projects to bluetooth serial comms?
- wdfx 2y agoYou can just buy a very cheap module which does this directly, commonly called HC-06 or HC-05 e.g. https://www.aliexpress.com/item/33010159305.html?spm=a2g0o.productlist.main.3.58a9918ebDZ2YA&algo_pvid=f3ba1982-f40f-41d4-b95e-6d3d097c078a&algo_exp_id=f3ba1982-f40f-41d4-b95e-6d3d097c078a-1&pdp_npi=4%40dis%21GBP%211.32%210.92%21%21%211.64%211.14%21%4021038da617315067335777331e2a1b%2110000001211713127%21sea%21UK%210%21ABX&curPageLogUid=CStUcUzXDpB6&utparam-url=scene%3Asearch%7Cquery_from%3A https://www.aliexpress.com/item/33010159305.html?spm=a2g0o.p...
- HeyLaughingBoy 2y agoYou can, of course, DIY something easily enough but you can also purchase devices like this off the shelf. Needing to make legacy RS232 devices wirelessly available is a common problem in industry. Search for "wireless RS232 gateway" and you should be able to find a ton of stuff. If you still want to DIY, an ESP32 (BLE and Wi-Fi capable microcontroller) board, and an RS232 to logic-level breakout board should be all you need. Again, I'm sure if you search, you'll find existing projects doing exactly this. If it's not actually at RS232 voltage levels and Classic Bluetooth is enough, then something like this will work just fine: https://www.amazon.com/Wireless-Bluetooth-Transceiver-Integrated-Communication/dp/B09GLLKLS4/?th=1 https://www.amazon.com/Wireless-Bluetooth-Transceiver-Integr...
- agapon 2y agoYou may find esp-link interesting: https://github.com/jeelabs/esp-link https://github.com/jeelabs/esp-link I've built a WiFi<->RS232 bridge using the firmware, ESP8266 and a UART<->RS232 converter module. All hardware is very cheap.
- jwr 2y agoThis is a wonderful hack! But — using a Raspberry Pi and Linux is overkill for this. It introduces huge unnecessary complexity. A simpler approach would be to go with Zephyr and a small microcontroller (ARM Cortex M4).
- 0_____0 2y agoIt's not unnecessary complexity if the thing wouldn't get made otherwise, especially for a personal project.
- imhoguy 2y agoRight, I think it is doable (an would say even easier/faster) with Raspberry Pico Pi W controller, it has BT and can behave like USB HID device.
- JoBrad 2y agoa.k.a. > A delightfully over-engineered solution
- bahaaador 2y ago<3
- bahaaador 2y agoThank you! I think that's a fair point about potentially wasted resources, something like Pico would have been and a leaner choice if this was going to be mass-produced. But for me, part of the decision was my comfort level with system programming and what I desired to tinker with and learn along the way and still, it's a very affordable option (around 20 CAD I believe) Perhaps I'll look into porting it to Pico in future as new challenge and learning experience. Thank you for your sharing your thoughts.
- imhoguy 2y agoI had same worries like yours but worry not, check MicroPython/CircuitPython when you get a chance. You load it up onto Pico and play with REPL in IDE. It is easier than debugging Go on large-RPi.
- draxil 2y agoI can't get past someone not being allowed to turn on bluetooth!
- athom 2y agoMy workplace doesn't even allow us to plug in (unapproved?) USB devices, so even this workaround likely wouldn't fly here.
- vardump 2y agoEasy to spoof a whitelisted device. Of course this might risk your future employment…
- reaperducer 2y agoSame here. I once plugged my personal phone into the USB port of a random machine in the office to get a quick charge, and a guy from Information Security showed up in under ten minutes ready to have a heart attack.
- imhoguy 2y agoCool stuff! Actually that tempts me to start a new rabbit hole research: could we do BT -> Internet -> BT. I would have so many uses to that.
- bahaaador 2y agoThank you, I'm glad you're finding this inspiring. I've been thinking about some similar ideas that excite me. Would be happy to help as well if you ran into any blockers.
- trklausss 2y agoWell, you need a frame converter that sends it to an IP address/DNS server, and on the receiving side something that receives that packet on a specific port and translates it to a BT command. I would say the most complicated part would be the TCP/IP stack, and binding/publishing your address, but if you are running something with Embedded Linux it is doable :)
- mtucker502 2y agoESPHome has this feature (called btproxy). It works well with BTLE devices. I use it for remote temperature sensors and a few other IoT btle devices. https://esphome.io/components/bluetooth_proxy.html https://esphome.io/components/bluetooth_proxy.html
- g1sm 2y agoThis seems to be specific to Home Assistant: > Note that while this component is named bluetooth_proxy, only BLE devices (and their Home Assistant integrations) are supported. One specific use-case I have in mind is controlling a Chromecast over the internet. So a smartphone should have its bluetooth signal relayed over an IP network. I haven’t found anything that would allow me to do that yet.
- sciencesama 2y agoHp had a wifi mouse !! https://www.techspot.com/review/420-hp-wifi-mouse/ https://www.techspot.com/review/420-hp-wifi-mouse/
- lemonwastaken 2y agovery cool
- fffrantz 2y agoDamned, I just purchased a new keyboard with a 2.4 GHz dongle because my Bluetooth keyboard cannot with GRUB and I got tired of having to plug it in every time I rebooted. What a cool little project. I might build a couple of these for the KVMs at work.
- bahaaador 2y agoOops, I hope you can still return it! I'm glad you might find this useful, be sure to create an issue on GH in case you run into any and I'll try my best to help :)
- rkagerer 2y agoSo it's basically what I would expect to get if I asked for a generic Bluetooth dongle.
- bahaaador 2y agoNot quite, if your PC has a policy that disables Bluetooth, a BT dongle would not work either. That’s where this relay comes in—it bridges Bluetooth to USB, so you can still use your devices.
- theblazehen 2y agoThis would also work to allow you to use a BT keyboard / mouse in UEFI setup etc I believe
- fffrantz 2y agoI think it should, yes. I'm going to try as soon as I can find my raspberry pi buried in the garage. It should work anywhere a USB keyboard works, realistically.
- rkagerer 2y agoBut that's exactly what I would want in the first place. Take my square and make it look like a circle (not a square with rounded corners).
- ChrisMarshallNY 2y ago> This project was born out of a desire to help a friend who couldn't use his favorite Bluetooth mouse and keyboard due to Bluetooth being disabled on his work laptop. Protip: If their company's IT section is like the one at my old company, they are quite unlikely to like this solution, either. But it's very clever. Kudos.
- bahaaador 2y agoThank you for sharing your thoughts, I had thought about this as well but came to the conclusion that from the company's perspective, this is no different than connecting a random keyboard bought from Amazon, what do you think? Another thought around this is that I don't even think there's anything intrinsically insecure about BT as an attack vector but most likely some old policy based on security issues that existed in the early days of Bluetooth. Or at least I don't know of any, but I'm no expert in this so I would love to hear other people's insights here.
- ChrisMarshallNY 2y agoIn my experience, the IT section didn't trust anything they didn't approve, themselves. They certainly wouldn't allow us to buy any random device from Amazon. It sucked. Big time, but they had the clout.
- jchw 2y agoIn my experience, I just never asked for permission when I was going to work around an annoying policy. I think while the company IT department will not love you, as long as you don't show up in one of their dashboards, it's pretty unlikely they will care. For years. Even if someone does bug you, I doubt it will amount to much other than being forced to adhere to the policy. As long as you ensure it doesn't look too much like you did it on purpose. (I would at least recommend a nice case for the device and picking innocuous USB IDs. Might be able to make it seem like a reasonable looking product, like a normal wireless keyboard receiver.) Remote work at startups has largely removed my need for this kind of behavior. Now I'm mostly just mad that I can't always run Linux at work anymore.
- WhitneyLand 2y agoCan’t imagine when I’ll ever need this, but I love it. Great work Bahador.
- bahaaador 2y agoThank you so much!
- threecheese 2y agoA potential use case for this is using BT-only peripherals, like Apple Magic Trackpad/keyboard, with KVM/USB switches. Would this work? I’d buy one. I currently have to use Synergy to share peripherals between two MacBooks.
- givinguflac 2y agoHave you tried usb? My Magic Trackpad and keyboard work fine without BT on both windows and pop os. Would love a way to actually disable the radios though.
- yencabulator 2y agoAt least older models of Apple Magic Trackpad work over USB just fine. I have one plugged via USB to my monitor, which acts as a KVM.
- jasomill 2y agoMagic Trackpad 2 and (Mac) Magic Keyboards appear as USB HID devices when connected to a computer via Lightning-to-USB (-A or -C) cable. One annoyance is that macOS automatically Bluetooth pairs with these devices when connected via USB, overwriting any existing pairing, but this shouldn't matter for purely wired scenarios. For switching Bluetooth devices more generally, observe that most Bluetooth controllers are USB devices; with a bit of effort — mostly just copy/pasting the device pairing keys across all connected hosts — they can be switched just like any other USB peripheral (YMMV with "intelligent" USB KVM switches that virtualize USB HID device connections). IME the connection delay is a couple seconds longer than switching wired USB HID devices directly, but entirely reasonable for typical KVM use cases. Note here that "most Bluetooth controllers are USB devices" even extends to internal Wi-Fi/Bluetooth combo cards, which are commonly M.2 key A or E (= PCIe + USB 2.0 + …), or M.2 key A or E preinstalled on a mostly passive PCIe adapter, with a separate cable connection to a USB port or motherboard USB header used exclusively for Bluetooth. This turns out to be a surprisingly useful implementation detail: on one of my work desktops, I'm currently virtual USB-switching the Bluetooth controller on an Intel BE200 PCIe card between a Linux host and a Windows VM running on that host, while keeping Wi-Fi connected to the host. I have a matching hot key set up in each OS to attach/detach the Bluetooth controller from the VM and simultaneously DDC switch the monitor input between the host (iGPU) and guest (PCIe dGPU passthrough), and it works great. Coincidentally, the Bluetooth devices I'm using in this configuration are a Magic Trackpad 2, a Magic Keyboard, and a Magic Mouse (the mouse was the motivation for using Bluetooth over USB in the first place, as, unlike the other Apple input devices, it's physically impossible to use when connected via USB).
- 76SlashDolphin 2y agoOoh, one thing that can be very useful for this is sending USB wakeup packets. I have an HTPC under my TV and game controllers (PS4, Xbox) at my coffee table and there is no way to wake up the PC with those over Bluetooth so I have to keep it on and idling at all times, wasting electricity.
- baq 2y agoIf you have a wired connection to the box you should be able to use wake on lan from a phone (this is what I used to do, now homeassistant took over this responsibility).
- mschuster91 2y agoI'd love to see something like this but the other way around - a native implementation of a Bluetooth mouse and keyboard in either Android, an iPhone or a RPi with a touchscreen. It would make life in a server rack so much easier if I didn't have to lug around a physical keyboard and mouse...
- bahaaador 2y agoOh interesting, I can see how something like that would be useful for myself as well. I think you just gave me some good ideas for future projects as I have a few ideas around using Bluetooth in React Native apps and potentially amalgamating them with Single-board computers. Thank you!
- myself248 2y agoBlackberries could do that, I think it was called Blackberry Connect or something like that. I used to use my Bold as a keyboard for my laptop when it was parked next to the projector.
- bashtian 2y agoFor Android there is an app that does this. https://play.google.com/store/apps/details?id=io.appground.blek https://play.google.com/store/apps/details?id=io.appground.b...
- mschuster91 2y agoThis right here is why I love HN. I've searched for years for this. Thanks so much.
- Nexxxeh 2y agoExcuse the dumb question, but could I then pair this with OP's project, to give myself a USB wireless keyboard and mouse while only carrying my phone and a Pi Zero 2 W?
- Derbasti 2y agoAwesome! This will finally let me use bluetooth devices behind a KVM!
- abind 2y agoAwesome! I was going to build something like this for myself for connecting peripherals behind a KVM. I gotta test how this works with the Magic Trackpad. IIUC Magic Trackpad does something non standard to achieve smooth scroll.
- bahaaador 2y agoI would be interested to know too, be sure to let me know how it goes!
- pwizzler 2y agoBluetooth was disabled but the USB port... wasn't?
- bambax 2y agoYes, that's weird. USB is a worse attack vector than Bluetooth.
- vel0city 2y agoUSB requires physical access. Bluetooth doesn't.
- bahaaador 2y agoI know, it seemed to me like a pretty arbitrary policy as well, but what can you do other than turning limitations into opportunities? ¯\_(ツ)_/¯
- atomicUpdate 2y agoThe reasoning I’ve heard is that Bluetooth traffic is easily snoopable without physical access to the device. Someone could potentially steal password keystrokes while sitting outside the office building, on the other side of a window with the shades drawn, whereas with USB you still need to get past the physical security and be at their desk.
- guilhas 2y agoIn my company USB port is generally disabled for storage and docks, but HID devices, like keyboards, work
- reeddavid 2y agoThis solves a huge annoyance I've had: swap a Bluetooth keyboard/mouse between multiple laptops, without manually un0paring / re-pairing. I have a personal "hot desk" at home. I want to be able to plug in any laptop to the large monitor, and have the wireless keyboard/mouse on that desk instantly work. And when I leave the desk with my laptop, I don't want that keyboard/mouse connected anymore. This has been impossible so far, because even USB bluetooth dongles still require each host computer to pair (and un-pair) with the keyboard/mouse. I am going to try your solution, and I will plug the USB input into the large monitor on my desk. Then any laptop that plugs into that monitor should have access to the wireless keyboard/mouse. Thank you for creating and sharing this!
- mmh0000 2y agoAll of this is being insanely overcomplicated. Throwing more complexity at a simple problem might be "fun" from a nerd's POV, and, TBH, building this USB device sounds fun. But entirely unneeded while introducing more points of failure. A simple solution to your problem: 1. Get a monitor with a built-in USB hub (nearly all of them?). Consider getting a USB-C monitor to reduce the number of cables to 1. 2. Don't use Bluetooth (for a keyboard, for multiple reasons, like needing the keyboard available in early boot). Get a keyboard/mouse with an external USB dongle like Logitech's Unify or Bolt, Corsair's SLIPSTREAM, or any of the other billion options that exist. 3. Plug keyboard/mouse into monitor, plug random computers into monitor. Bam. Unified mouse and keyboard without any pairing.
- FredFS456 2y agoA cheap USB switch would also work, that would reduce the switching to switching monitor inputs and pressing the button the USB switch
- seiferteric 2y agoI did this for a while but was a bit annoyed with the delay since it "unplugs" and "plugs" in the mouse/keyboard each time you hit the button. What I ended up doing is buying a used KVM switch with DDM (https://en.wikipedia.org/wiki/Dynamic_device_mapping https://en.wikipedia.org/wiki/Dynamic_device_mapping) which allows pretty much instant switching.
- Havoc 2y agoDoes this support headphones/audio too?
- rainbowskys 2y agoAudio support would be awesome. I would love to be able to use my AirPods and other Bluetooth headphones on gaming consoles
- vel0city 2y agoAs someone who uses Bluetooth headphones on a Switch and gaming PC from time to time, it's generally not a great experience. Computers and phones and what not compensate for the delay often for video sources, but low latency gaming can become noticeable for things like SBC and what not. Those proprietary wireless headphones are doing a lot to try and optimize the latency.
- bahaaador 2y agoNot at the moment, I might look into it as I've received the request a few times now. So stay tuned! :)
- Havoc 2y agoThank you! Currently fight (and losing) a battle with Sony headphones on windows & LDAC protocol
- willwade 2y agoNice. Check out this guys repos for stuff using nrf chips. It’s generally the other way round. Really nice. https://github.com/gdsports/ble-usb-devices https://github.com/gdsports/ble-usb-devices https://github.com/gdsports/usbhostcopro https://github.com/gdsports/usbhostcopro
- tanvach 2y agoThis is very cool. I have a Kinesis Freestyle2 Blue for Mac that keep having repeating key issue when paired with my Macbook. The Kinesis CS unhelpfully blame Apple's BT stack implementation and offered no solution. I never had issues with the keyboard when connected to a Linux machine, so this will work nicely for my home office setup! I'm assuming this also works with Pi Zero 2 W? (The repo only mention the original Zero W)
- bahaaador 2y agoActually, I meant to say Pi Zero 2 W as well. But basically, any device that supports USB OTG
- grnnja 2y agoRelated nrf52 based project: https://github.com/jfedor2/hid-remapper/blob/master/BLUETOOTH.md https://github.com/jfedor2/hid-remapper/blob/master/BLUETOOT...
- maxglute 2y agoThank you, I was looking for something similar years ago and was surprised there wasn't rando product on aliexpress.
- mococa 2y agoI have a USB switch, this will help me to use with my bluetooth devices. Thank you!
- 112233 2y agoIs there or can this be used as reverse thing -- plug stuff into usb hub, and it shows up as a BLE HID?
- lamnguyenx 2y agoDoes this work with Raspberry Pi 4 or Raspberry Pi Zero 2 W? Unfortunately I don't have Pi Zero W lying around :(
- bahaaador 2y agoAny SbC with OTG support should work, so both Zero W and Zero 2 W should be compatible (I tested it with RPi Zero 2 W—I will update the docs). https://www.raspberrypi.com/products/raspberry-pi-zero-2-w/ https://www.raspberrypi.com/products/raspberry-pi-zero-2-w/ https://www.raspberrypi.com/products/raspberry-pi-zero-w/ https://www.raspberrypi.com/products/raspberry-pi-zero-w/ I can't find definitive information for RPi 4 though, I see some references to using it online but the spec here does not seem to mention USB host or OTG https://www.raspberrypi.com/products/raspberry-pi-4-model-b/specifications/ https://www.raspberrypi.com/products/raspberry-pi-4-model-b/...