Connect Apple Magic Keyboard and Apple Magic Mouse to HC-05

I would like to connect my Apple Magic Keyboard and my Apple Magic Mouse to arduino via bluetooth but I just can't figure out how to do it.

The problem is that both devices have a password and therefore I don't know how to pair with my HC-05 board and my Arduino Uno.

Would anyone know how to give me some advice?

I doubt you'll get this working. Your HC-05 advertises an SPP profile and this is not what's used for a keyboard or mouse.

Also, the HC-05 is a BT 2.0 component and the Apple stuff uses a Broadcom BCM20733 Enhanced Data Rate chip leveraging Bluetooth 3.0.

2 Likes

Hi, Thanks for your reply.
Do you have any advice on what I can do?

My goal is the following:
I would like to use my input devices on 2 devices (macos and windows).
My idea is to connect my Apple Magic Keyboard and my Apple Magic Mouse to arduino via bluetooth so as to take the signal and use arduino as a HID proxy that will send the data via the usb.

Any idea on which device I can use to be able to connect these devices to arduino?

with BT you are in for all sorts of pains...

I'd look at doing stuff with an ESP32 (see. esp-idf/examples/bluetooth/esp_hid_host at 16a4ee7c36a848ca155791677ce011f3ca75c519 · espressif/esp-idf · GitHub)

and possibly drive a couple slave ESP that would be attached to the target PCs which would pose as a keyboard and mouse...

I'm not too sure what's the end use case but KVM are not so expensive those days...

Hi @PierAndrea , did you solve your issue?

I am facing a similar problem. I would like to connect an Apple Magic Trackpad (1. gen) to the HC-05 to forward its signals to USB HID (additionally I would like to preprocess the signals to get more gestures). I thought a DIY build would be the only option to do that?

@J-M-L , do you know of any KVM switches, which allow a Bluetooth mouse/keyboard to be connected?

That’s not possible to my knowledge


what are you trying to achieve ? use your mouse and keyboard as input device for an arduino? (which one)

you cant connect using USB-B because its used to give energy but it gets energy (+5v)

I wanted to achieve something similar to @PierAndrea, i.e. connect the trackpad to some device via Bluetooth and then forward the mouse control signals via USB to the computer, so that I can do some preprocessing in between, e.g. add more gestures. Most importantly I wanna have that without requiring any specific driver for the OS.

See Pre-process and forward bluetooth mouse input as USB mouse output - how to get started?

That way, the trackpad would be connected via USB, so that I can plug it into a docking station and swap computers by a single connector, as well as having advanced trackpad gestures without requiring any driver.

It looks like I am on the wrong way with the HC-05. I would definitely need a BT Classic (2.0) capable device though and as far as I know the ESP32 devices only support BLE. Do you know of any other devices or modules, which support pairing with a BT Classic mouse/trackpad?

The ESP32 comes with Wi-Fi, Bluetooth Low Energy and Bluetooth Classic

Yeah, you're right. Thanks for the clarification. I think I am getting confused with all the versions of the ESP32. I remember I didn't find any ESP32 board on my (long) research, which supports both, BT Classic and USB HID emulation. The ESP32 does have BT Classic support, but doesn't seem to support USB HID emulation, while the ESP32-S2 seems to support it, but doesn't have BT Classic support (ESP32 HID Keyboard USB - ESP32 Forum, https://gist.github.com/sekcompsci/2bf39e715d5fe47579fa184fa819f421, MGC | HID Mouse Emulation using ESP32).

Am I right with that finding? (still not confident with all the specifications)

You are right it’s a bit of a jungle out there

ESP32 S2 does not have BT indeed but has USB Host/master role, the C3 does have BT 5.0 + BLE but does not support USB Host.

A good video

1 Like

The ESP32-S3 has USB OTG (host and device) and has Bluetooth Low Energy (BLE) but does not have Bluetooth Classic. Only the original ESP32 has BLE and BT classic.

You could connect an RP2040 (Pi Pico) to the ESP32 to get USB HID mouse output. Your choice of UART, SPI, or I2C.

1 Like

Thanks @J-M-L for the informative video!
Thanks @Icebuster for the suggestion! I thought about that, i.e. whether it is possible to connect some USB HID capable device to the ESP32 to add the USB HID functionality. The Pi Pico seems like an option. What do you think about the Arduino Micro. As I now already have one laying around, would that be an option too or would it make things more complicated, or slower / produce more latency? (i saw that the Pi Pico uses an ARM Cortex-M0+, 2x 133MHz, while the Arduino Micro has an Atmel ATmega32u4 with only 16MHz)

The latency is subjective - depends what you want to use the device for and how you handle the communication

Yeah, it is subjective. However, does anybody have an idea with which combination I could expect minimum latency? (Usecase: Bluetooth trackpad input -> processing -> HID USB mouse output)

well - seems the processing piece is the unknown there. The faster it will get done the better.. .so a fast processor would help

1 Like

Since you have a Micro you should be able to run the USB mouse examples to get some idea of what is involved on the software side. This is the easy part compared to Bluetooth on ESP32.

The Micro uses 5V logic levels (the ESP32 uses 3.3V) so interfacing via UART avoids the need for logic level converters. For example, connect ESP32 Serial1 TX to Micro Serial1 RX. And connect ground. Set both serial ports to 115,200 bits/sec. That is 11,520 bytes per second so transmission latency should be pretty low. The USB mouse HID report is only 4 byte long. If this is too slow there may be higher UART speeds available.

There is not much work for the Micro or RP2040 to do. In loop(),

  • read 4 bytes from Serial1
  • write the 4 bytes to USB HID interace.
1 Like

That's very helpful comments, thank you!

I see, so I would do the actual gesture processing on the ESP32 and let the Micro just forward basic movement/click commands. I expect the latter to be fairly simple.

I currently mainly have doubts regarding the Bluetooth pairing and reading part on the ESP32. I am having hard times trying to find any project, which involves pairing any Bluetooth Classic keyboard/mouse/trackpad to a ESP32, so I don't really have an idea how complicated that is or whether it is actually possible? Can anybody confirm that for sure? Is it as simple as pairing one with a PC?

Finally reading the Bluetooth input and decoding it might be complex too, but I feel it is possible given there still is enough motivation to do it :slight_smile:

Probably worth getting your hands dirty and try things out now

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.