Skip to content

Commit 2661c0a

Browse files
committed
[usb_cdc_acm] New component documentation
1 parent 83901b5 commit 2661c0a

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

content/components/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ Create update entities simplifying management of OTA updates.
168168
"OpenTherm","components/opentherm","opentherm.png",""
169169
"SPI Bus","components/spi","spi.svg",""
170170
"UART","components/uart","uart.svg",""
171+
"USB CDC-ACM","components/usb_cdc_acm","usb.svg","dark-invert"
171172
"USB Host","components/usb_host","usb.svg","dark-invert"
172173
"USB UART","components/usb_uart","usb.svg","dark-invert"
173174
{{< /imgtable >}}

content/components/usb_cdc_acm.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
description: "Instructions for setting up USB CDC-ACM virtual serial ports on ESP32 variants in ESPHome"
3+
title: "USB CDC-ACM Interface"
4+
params:
5+
seo:
6+
description: Instructions for setting up USB CDC-ACM virtual serial ports on ESP32 variants in ESPHome
7+
image: usb.svg
8+
---
9+
10+
The USB CDC-ACM (Communications Device Class - Abstract Control Model) component enables ESP32-S2 and ESP32-S3 devices
11+
to function as USB virtual serial ports. When connected to a host computer, the microcontroller will appear as one or
12+
more standard serial/COM ports, allowing serial communication with the application running on the microcontroller.
13+
14+
You must have the TinyUSB component in your device's configuration to use this component.
15+
16+
> [!NOTE]
17+
> This component is only compatible with ESP32-S2 and ESP32-S3 variants using the ESP-IDF framework.
18+
19+
```yaml
20+
# Example minimal configuration entry
21+
usb_cdc_acm:
22+
interfaces:
23+
- number: 0
24+
```
25+
26+
## Configuration variables
27+
28+
- **usb_rx_buffer_size** (*Optional*, int): Size of the USB receive buffer in bytes. Range: 1-65535. Defaults to `256`.
29+
- **usb_tx_buffer_size** (*Optional*, int): Size of the USB transmit buffer in bytes. Range: 1-65535. Defaults to `256`.
30+
- **interfaces** (**Required**, list): List of CDC-ACM interface instances to configure; up to two are supported. At
31+
least one is required.
32+
33+
## Interface configuration variables
34+
35+
Each interface in the `interfaces` list supports the following options:
36+
37+
- **id** (*Optional*, [ID](#config-id)): The ID to use for this interface instance.
38+
- **number** (**Required**, int): Unique interface identifier. Valid values are `0` or `1`. Each configured interface
39+
must have a unique number.
40+
41+
## Multiple Interface Example
42+
43+
The USB CDC-ACM component supports up to two simultaneous virtual serial port interfaces on a single device. This
44+
allows you to create multiple independent communication channels over a single physical USB connection.
45+
46+
```yaml
47+
# Example configuration with two interfaces
48+
usb_cdc_acm:
49+
interfaces:
50+
- id: cdc_acm_1
51+
number: 0
52+
- id: cdc_acm_2
53+
number: 1
54+
```
55+
56+
In this configuration, the device will appear as two separate serial/COM ports to the host computer. Each interface
57+
operates independently with its own data buffers.
58+
59+
## Buffer Size Considerations
60+
61+
The buffer sizes determine how much data can be temporarily stored during USB transfers:
62+
63+
- **Small buffers (256 bytes, default)**: Suitable for low-bandwidth applications and conserves RAM
64+
- **Large buffers (512-1024 bytes)**: Recommended for high-throughput applications or when handling bursts of data
65+
66+
Increase buffer sizes if you experience data loss or need to handle larger data packets without frequent polling.
67+
68+
## See Also
69+
70+
- {{< apiref "usb_cdc_acm/usb_cdc_acm.h" "usb_cdc_acm/usb_cdc_acm.h" >}}

0 commit comments

Comments
 (0)