What is it?
Control devices with a virtual usb keyboard/mouse.
How does it work?
The arduino is emulating HIDs (Human Interface Devices) such as keyboard/mouse via USB
The ESPHome board is receiving commands via wifi/mqtt and writes them to the serial port
The commands are in Ducky Script syntax
The commands are read from the serial port by the arduino and executed as keyboard/mouse actions
Furthermore it’s possible to get the host machine’s power state from the USB state via the serial port
For example, this will open up notepad and type some text in it:
service: mqtt.publish
data:
topic: esphome/nodemcu/run
payload: |
GUI r
DELAY 200
STRING notepad.exe
ENTER
DELAY 200
STRING Hello World
You can do basically everything that a keyboard and mouse can do. Media keys and power buttons are also supported. See github project for more information.
More examples:
I have just tested a rpi pico, which work out of the box as a HID device. My use case is slightly different, connecting physical buttons and a rotary encoder to a media player. You could join the pico to an esp to make a wifi device.
Hi, the device you’ve linked uses a different communication protocol (I²C instead of serial), so you would have to adjust that in both firmwares. I haven’t tried it myself though.
Really cool project, @jwm
What do you think of the idea to let the Bluetooth radio of a ESP32 emulate a Bluetooth keyboard directly to the computer?
I found this, so the emulation part could work, I guess. But don’t know if you can combine the code to use Bluetooth to the computer, and Wi-Fi to the Home Assistant server.
Edit: I now see that you wrote about something similar a few posts from the end.
But feel free to comment anyway.
I tried that ble project and had some issues with android controls (power button IIRC) and some reconnect problems after sleep of the android-box. So I’m still using the arduino over usb.
In general I find NicoHood’s usb library (which my project uses) much more powerfull especially with special keys (even gamepad is possible) or different language layouts.
hey, I know this is a late follow up, but did you have any success with the Wifi Duck?
I’m also looking to power on my laptop and wol does not work through my thunderbolt dock, so this looks like an interesting solution…
I successfully got this to work when plugged into my desktop. However when I plugged it into my tesmart KVM (HKS0202A2U) It wouldn’t pick up on the HID Keystrokes. Do you have any ideas why this didn’t work as expected?
Since it has hotkey switching, I guess that it’s not passing through the arduino. Instead it will interpret the keyboard commands itself first and mimic the commands to the pc?
The arduino board firmware does setup 4 hid devices in the code. Maybe the kvm switch cannot handle that. You can try to enable only the keyboard, maybe this will work.