zejulio
(Julio Silva)
January 5, 2024, 10:47am
1
Hello,
It would be great if we could have a component that makes ESP32 act like an USB Keyboard, see several loose projects about this.
My idea is to control my TV setup box, that has a RF remote. But I can use a keyboard/mouse on the USB port to control it.
If I can send the keys from ESPHome device would be great.
I know there is a project similar, but uses ESP8266 and a ATMEL, my goal is to keep it all with just one ESP32.
Receive data from HA-WIFI-USB»Setup Box
Is there anything like this?
1 Like
There is this lib GitHub - chegewara/esp32-usb-v2: ESP32S2/S3 native USB library. Implemented few common classes, like MIDI, CDC, HID or DFU (update).
Woule be great to have a working example for esphome! (Even if just via custom component) for ESP32-S3 / S3
Also
Both under esp-idf not arduino
pkscout
(Kyle Johnson)
August 21, 2025, 9:51am
3
This doesn’t use ESPHome, but I did build an arduino based remote “base station” that you can plug a USB dongle into from an RF remote and have it pass commands to HA using MQTT. I tried making a custom component for ESPHome, but it was well beyond my understanding, and the docs for building a custom component apparently assume you already know how to build a custom component.
Contribute to pkscout/arduino-remote development by creating an account on GitHub.
Hellis81
(Hellis81)
August 21, 2025, 3:16pm
4
dev
← tomaszduda23:dev
opened 06:56PM - 18 Oct 22 UTC
# What does this implement/fix?
Emulating a USB keyboard.
It needs:
- https… ://github.com/esphome/esphome/pull/7520
- https://github.com/esphome/esphome/pull/7513
Optional:
- https://github.com/esphome/esphome/pull/7210
**Quick description and explanation of changes**
It adds dependency to https://github.com/adafruit/Adafruit_TinyUSB_Arduino.
## Types of changes
- [ ] Bugfix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Other
## TODO
- [x] add esphome/components/web_server/server_index_v2_keyboard.h
- [x] framework-arduinoespressif32 uses tinyusb behind
- [x] part of implementation is duplicated in this PR already
- [ ] check esp32-idf https://github.com/espressif/esp-idf/blob/636ff35b52f10e1a804a3760a5bd94e68f4b1b71/examples/peripherals/usb/device/tusb_hid/main/tusb_hid_example_main.c
- [ ] check rpi pico https://github.com/raspberrypi/pico-examples/tree/master/usb/device/dev_hid_composite
- [x] check how to add new device type. This is needed for web server.
**Related issue or feature (if applicable):** fixes <link to issue>
https://github.com/esphome/feature-requests/issues/1918
**Pull request in [esphome-docs](https://github.com/esphome/esphome-docs) with documentation (if applicable):** esphome/esphome-docs#<esphome-docs PR number goes here>
## Test Environment
- [ ] ESP32
- [ ] ESP32 IDF
- [ ] ESP8266
- [x] ESP32-S2
- [x] ESP32-S3
## Example entry for `config.yaml`:
```yaml
external_components:
- source: github://pr#3917
components: [hid, keyboard, usb_device, web_server, component_iterator, api]
refresh: always
esphome:
name: esp-white-control
board: lolin_s2_mini
platform: ESP32
web_server:
local: true
button:
- platform: template
name: "Press ShiftLeft + B"
on_press:
then:
- keyboard.down:
id: kbd
keys:
- ShiftLeft
- 5
- delay: 100ms
- keyboard.set:
id: kbd
- platform: template
name: "Press K"
on_press:
then:
- keyboard.down:
id: kbd
keys: KeyK
- delay: 100ms
- keyboard.up:
id: kbd
keys: KeyK
- platform: template
name: "Press volume up"
on_press:
then:
- keyboard.set:
id: kbd
keys: 0x00E9
type: media_keys
- delay: 100ms
- keyboard.set:
id: kbd
type: media_keys
- platform: template
name: "Press volume down"
on_press:
then:
- keyboard.set:
id: kbd
keys: 0x00EA
type: media_keys
- delay: 100ms
- keyboard.set:
id: kbd
type: media_keys
keyboard:
- platform: hid
name: Blue kbd
hid_id: usb_hid
id: kbd
hid:
- platform: usb_device
id: usb_hid
type:
composite:
- keyboard
- media_keys
binary_sensor:
- platform: usb_device
mounted:
name: USB is mounted
ready:
name: USB is ready
suspended:
name: USB is suspended
- platform: keyboard
keyboard_id: kbd
capslock:
name: capslock
numlock:
name: numlock
scrollock:
name: scrollock
switch:
- platform: usb_device
detach:
name: Detach USB device
wake_up:
name: Wake up host
```
## Checklist:
- [x] The code change is tested and works locally.
- [x] Tests have been added to verify that the new code works (under `tests/` folder).
If user exposed functionality or configuration variables are added/changed:
- [x] Documentation added/updated in [esphome-docs](https://github.com/esphome/esphome-docs).
https://github.com/esphome/esphome-docs/pull/2414
Currently not working on the latest version of ESP-Home but using legacy ESP-Home works fine on, say December 2024 release