Skip to content

Commit f4f4d9c

Browse files
committed
Document usb_host_hid component
1 parent b6dd4f1 commit f4f4d9c

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

content/changelog/2025.10.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ These optimizations benefit all platforms, but ESP8266 users will notice the mos
267267
- **Configurable Ethernet MAC address** in YAML
268268
- **QMC5883L DRDY pin** for maximum sampling rate
269269
- **USB host/UART** support on ESP32-P4
270+
- **USB HID host** support (i.e. USB keyboard events) on ESP-IDF platforms
270271
271272
## For Contributors
272273
@@ -392,6 +393,7 @@ continue working, but custom components and advanced setups may require updates.
392393
- [api] Add support for getting action responses from home-assistant [esphome#10948](https://github.com/esphome/esphome/pull/10948) by [@jesserockz](https://github.com/jesserockz) (new-feature)
393394
- [epaper_spi] New epaper component [esphome#10462](https://github.com/esphome/esphome/pull/10462) by [@jesserockz](https://github.com/jesserockz) (new-component) (new-feature) (new-platform)
394395
- [usb_host] Fix transfer slot exhaustion at high data rates and add configurable max_transfer_requests [esphome#11174](https://github.com/esphome/esphome/pull/11174) by [@bdraco](https://github.com/bdraco) (new-feature)
396+
- [ush_host_hid] New USB Host HID component, allowing to receive USB keyboard inputs on ESP-IDF devices [esphome#9680](https://github.com/esphome/esphome/pull/9680) by [@zopieux](https://github.com/zopieux) (new-component) (new-feature)
395397

396398
### New Components
397399

@@ -681,6 +683,7 @@ continue working, but custom components and advanced setups may require updates.
681683
- [ota] Increase handshake timeout to 20s now that auth is non-blocking [esphome#11186](https://github.com/esphome/esphome/pull/11186) by [@bdraco](https://github.com/bdraco)
682684
- [esp32_improv] Fix state not transitioning to PROVISIONED when WiFi configured via captive portal [esphome#11181](https://github.com/esphome/esphome/pull/11181) by [@bdraco](https://github.com/bdraco)
683685
- [usb_host] Fix transfer slot exhaustion at high data rates and add configurable max_transfer_requests [esphome#11174](https://github.com/esphome/esphome/pull/11174) by [@bdraco](https://github.com/bdraco) (new-feature)
686+
- [ush_host_hid] New USB Host HID component, allowing to receive USB keyboard inputs on ESP-IDF devices [esphome#9680](https://github.com/esphome/esphome/pull/9680) by [@zopieux](https://github.com/zopieux) (new-component) (new-feature)
684687
- [media_player.speaker] Dynamic auto load [esphome#11084](https://github.com/esphome/esphome/pull/11084) by [@jesserockz](https://github.com/jesserockz)
685688
- [core] Properly clean the build dir in the HA addon [esphome#11208](https://github.com/esphome/esphome/pull/11208) by [@swoboda1337](https://github.com/swoboda1337)
686689
- Fix log retrieval with FQDN when mDNS is disabled [esphome#11202](https://github.com/esphome/esphome/pull/11202) by [@bdraco](https://github.com/bdraco)

content/components/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ Create update entities simplifying management of OTA updates.
169169
"SPI Bus","components/spi","spi.svg",""
170170
"UART","components/uart","uart.svg",""
171171
"USB Host","components/usb_host","usb.svg","dark-invert"
172+
"USB HID Host","components/usb_host_hid","usb.svg","dark-invert"
172173
"USB UART","components/usb_uart","usb.svg","dark-invert"
173174
{{< /imgtable >}}
174175

content/components/usb_host.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ usb_host:
2525
pid: 0x1234
2626
```
2727
28+
> [!NOTE]
29+
> This component cannot be used in combination with the
30+
> {{< docref "/components/usb_host_hid" >}} as both components need to assume
31+
> control of the plugged USB devices, which would create a conflict.
32+
2833
## Configuration variables
2934
3035
- **id** (*Optional*, [ID](#config-id)): The id to use for this component.

content/components/usb_host_hid.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
description: "Instructions for setting up a USB HID Host interface on an ESP32 in ESPHome"
3+
title: "USB HID Host Interface"
4+
params:
5+
seo:
6+
description: Instructions for setting up a USB HID Host interface on an ESP32 in ESPHome
7+
image: usb.svg
8+
---
9+
10+
The USB HID Host interface on the ESP32-S2, ESP32-S3 and ESP32-P4 is used to
11+
connect to USB HID (Human Interface Device) peripheral devices, that is,
12+
keyboards and mouses. Multiple devices may be configured and connected at once.
13+
By default, devices must be directly connected to the ESP32, but this can be
14+
changed by setting the `enable_hubs` option to `true`.
15+
16+
This component only supports **keyboards** today. Key presses, assuming a
17+
standard US keyboard layout, will be accumulated internally. It is therefore
18+
most useful in combination with a {{< docref "/components/key_collector" >}} to
19+
do an action with the recorded keys, as illustrated below.
20+
21+
```yaml
22+
# Example configuration entry
23+
usb_host_hid:
24+
enable_hubs: true
25+
keyboards:
26+
- id: kbd_1
27+
vid: 0x1725
28+
pid: 0x1234
29+
30+
key_collector:
31+
- id: reader_1
32+
source_id: kbd_1
33+
# Collects whole lines of text, up to <Return>.
34+
end_keys: "\r"
35+
timeout: 1s
36+
# on_result:
37+
# ...
38+
```
39+
40+
> [!NOTE]
41+
> This component cannot be used in combination with the
42+
> {{< docref "/components/usb_host" >}} as both components need to assume
43+
> control of the plugged USB devices, which would create a conflict.
44+
45+
## Configuration variables
46+
47+
- **id** (*Optional*, [ID](#config-id)): The id to use for this component.
48+
- **enable_hubs** (*Optional*, boolean): Whether to include support for hubs.
49+
Defaults to `false`.
50+
- **keyboards** (*Optional*, list): A list of keyboard devices to configure.
51+
52+
## Keyboard configuration options
53+
54+
- **id** (*Optional*, [ID](#config-id)): An id to assign to the device.
55+
- **check_class**: (*Optional*, boolean): Whether to check the device's HID
56+
class is indeed “keyboard”. Defaults to `true`.
57+
- **vid** (**Required**, int): The vendor ID of the device. Use 0 as a wildcard.
58+
- **pid** (**Required**, int): The product ID of the device. Use 0 as a wildcard.
59+
60+
If a device is configured and a device is connected that matches the
61+
configuration, the device will be connected to the ESP32 and log entries will
62+
appear at the DEBUG level. If the log level is set to VERBOSE, then individual
63+
key presses will be logged. The device will remain connected until it is
64+
disconnected or the ESP32 is reset.
65+
66+
> [!WARNING]
67+
> If multiple devices are plugged in that match the same wildcard
68+
> configuration, only the first one will be correctly handled. A log entry at
69+
> WARNING level will appear for subsequent conflicting devices. Make sure you
70+
> have one `keyboards` configuration declared for each of the devices you intend
71+
> to plug in, and that they do not overlap with each other.
72+
73+
If a device is plugged in that does not match any configured device, it will be
74+
ignored and a log entry will appear at the DEBUG level.
75+
76+
If a configured device is plugged in that does *not* declare itself as a HID
77+
keyboard, it will be ignored and a log entry will appear at the WARNING level.
78+
Some devices may work just fine (they report key presses) with this component,
79+
but do not declare themselves as keyboards, in which case you can set
80+
`check_class` to `false`.
81+
82+
### See Also
83+
84+
- {{< docref "/components/usb_host" >}}
85+
- {{< apiref "usb_host_hid/usb_hid.h" "usb_host_hid/usb_hid.h" >}}

0 commit comments

Comments
 (0)