houkanshan / arduino-bt-hid-proxy

Bluetooth HID proxy is implemented using Arduino. Make a Bluetooth keyboard or mouse (WIP) work in BIOS or device without BT stack (e.g. TMK USB to USB Converter)
88 stars 4 forks source link

Support for ESP32 #2

Open leopck opened 2 years ago

leopck commented 2 years ago

Great project, I love this project as this has been my pain point for sometime now and there's no solution in the market that is able to resolve this.

Is there any plans to adopt ESP32 with USB HID and Bluetooth as a single package solution for this? This would make it much leaner and smaller in package and if we turn off Wi-Fi, potentially it would be relatively low power as well.

leopck commented 2 years ago

Some good hardware to get started on is the latest version ESP32-S3: https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitm-1.html https://github.com/espressif/esp-dev-kits/tree/master/esp32-s3-usb-otg

Jerther commented 2 years ago

Hi!

Just my 2 cents. From what I gathered about the ESP32, only the ESP32-S2 supports Bluetooth HID Host. Can the S3 do that?

leopck commented 2 years ago

Actually ESP32-S2 doesn't come with Bluetooth while it does have WiFi and USB but not the Bluetooth hardware itself. ESP nowadays has many various hardware, so it's easy to get confused. I've provided some hardware table here to give a better idea on their hardware capabilities.

name type wifi bluetooth
ESP32-S3 SoC IEEE 802.11 b/g/n; 2.4 GHz; HT20/40; up to 150 Mbps Bluetooth LE v5.0
ESP32-C3 SoC IEEE 802.11 b/g/n; 2.4 GHz; HT20/40; up to 150 Mbps Bluetooth LE v5.0
ESP32-S2 SoC IEEE 802.11 b/g/n; 2.4 GHz; HT20/40; up to 150 Mbps N/A
ESP32 SoC IEEE 802.11 b/g/n; 2.4 GHz; HT20/40; up to 150 Mbps BR/EDR + Bluetooth LE v4.2
ESP8266EX SoC IEEE 802.11 b/g/n; 2.4 GHz; HT20; up to 75 Mbps N/A

Actually they have over 144 variants of this, for the full list of capabilities, you can see from here: https://products.espressif.com/#/product-selector?language=en&names=

Regarding the ESP32-Sx series supporting USB HID, yes, ESP32-S2 and ESP32-S3 both supports USB HID, there's a good examples and documentation using TinyUSB with ESP32-S2 and ESP32-S3 here: https://github.com/espressif/esp-iot-solution/tree/usb/add_usb_solutions/examples/usb/device/usb_hid_device

From their example: image

Makes me wonder if they support USB HID composite device (mouse + keyboard) example so that we can support both mouse and keyboard at the same time.

Seeing that this project is more focused on Bluetooth HID proxy, I would say ESP32-S3 would be most suitable with USB OTG with HID examples and Bluetooth capabilities available as well.

Jerther commented 2 years ago

Sounds very promising then! Should you or @houkanshan make an all-on-one solution with an ESP32, I'll be happy go get my hand on one and do some tests with my two bluetooth keyboards (Logitech K810 and K380). If mouse support is added, I also have a Logitech M535 Bluetooth mouse.

leopck commented 2 years ago

@Jerther I just realized that you were also asking about the BT HID host mode which is required to pair the keyboard/mouse into the ESP32, but doesn't seem like there's an existing example on BT HID host mode, but there's an example of using BT HID client mode (to act as a keyboard) https://gist.github.com/manuelbl/66f059effc8a7be148adb1f104666467

houkanshan commented 2 years ago

Hi @leopck @Jerther , thanks a lot! ESP32-S3 looks really cool. I just ordered one, when it arrives I'll play with it and see what I can get.

fkahhaleh commented 2 years ago

Please keep us updated, I am also interested in using the ESP32. Ordered the missing components for the ARDUINO version to play around with it but for sure would like a miniaturized ESP32 :).

Will keep an eye on this thread and maybe I can help with as well.

leopck commented 2 years ago

@houkanshan @Jerther I found a code that has implemented a Bluetooth HID Host mode accepting keyboard as input into ESP32. It might be worth a look at their implementation.

https://github.com/bozont/Duke3D/commit/51f1ce4f3b74f16f1adfc6fefc9d6afce2ef82d8

Demo video: https://www.reddit.com/r/esp32/comments/mtcpug/duke_nukem_3d_with_bluetooth_keyboard_control/?utm_medium=android_app&utm_source=share

Jerther commented 2 years ago

@houkanshan Did you get your S3? How is it? I hope you have some good news ;)

houkanshan commented 2 years ago

Hey @Jerther , I got it. But unfortunately I was not able to connect it to my Magic Keyboard (Bluetooth 3.0) so I did not continue at that time. I might try again later.

Jerther commented 2 years ago

@houkanshan I'd like to contribute but my knowledge and most of all my spare time are fairly limited. I'm still willing to get my hand on a proper ESP32 and do some tests for you, but I would need some directions. I have access to a logitech K810 and a K380.

If you're interrested, could you point me to the exact ESP32 make and model I should look for?

bam80 commented 7 months ago

Any progress?

If you're interrested, could you point me to the exact ESP32 make and model I should look for?

I think Wemos S3 MINI or C3 Boards are good candidates for this: https://www.wemos.cc/en/latest/c3/index.html https://www.wemos.cc/en/latest/s3/s3_mini.html

ejohb commented 2 weeks ago

Hi all.

I'm also very keen on this idea. Has there been any progress?

Failing that, are there any other projects implementing ESP32 support?