Skip to content

USB Host UART Interface

This component allows an ESP32-S3 or ESP32-S2 to host USB-serial peripheral devices. It uses the Usb Host component to interface to the device as a USB-OTG host.

Currently supported devices are listed in the table below:

NameVIDPIDDescription
CDC_ACM0x00000x0000USB CDC ACM (Abstract Control Model)
CH34X0x1A860x55D5USB to serial adapter, multi-channel
CH3400x1A860x7523USB to serial adapter, single channel
CP210X0x10C40xEA60Silicon Labs USB to UART Bridge
ESP_JTAG0x303A0x1001ESP32 JTAG interface
FT2320x04030x6001FTDI USB to serial adapter single port
FT22320x04030x6010FTDI USB to serial adapter dual port
FT42320x04030x6011FTDI USB to serial adapter dual port
PL23030x067B0x2303Prolific USB to serial adapter
PL2303GC0x067B0x23A3Prolific PL2303 G-series (GC)
PL2303GB0x067B0x23B3Prolific PL2303 G-series (GB)
PL2303GT0x067B0x23C3Prolific PL2303 G-series (GT)
PL2303GL0x067B0x23D3Prolific PL2303 G-series (GL)
PL2303GE0x067B0x23E3Prolific PL2303 G-series (GE)
PL2303GS0x067B0x23F3Prolific PL2303 G-series (GS)
STM32_VCP0x04830x5740STM32 Virtual COM Port

Note that devices with 4 channels will only allow 3 channels to be used at any one time on an ESP32-S3 due to hardware limitations. The ESP32-P4 is not affected by this limitation and can use all 4 channels.

# Example minimal configuration entry
usb_uart:
- type: cp210x
channels:
- id: uch_1
baud_rate: 9600
buffer_size: 1024
  • id (Optional, ID): The id to use for this component.
  • type (Required, string): The type of USB-serial device to connect to. One of ft23xx, ch34x, ch340, esp_jtag, stm32_vcp, cdc_acm, cp210x, pl2303, pl2303gc, pl2303gb, pl2303gt, pl2303gl, pl2303ge, pl2303gs.
  • channels (Required, list): A list of channels to configure.
  • vid (Optional, int): The vendor ID of the device. Use 0 as a wildcard. Each type has a default VID which will be overridden if this is set.
  • pid (Optional, int): The product ID of the device. Use 0 as a wildcard. Each type has a default PID which will be overridden if this is set.

Setting both vid and pid to 0 will match any device.

  • id (Optional, ID): An id to assign to the channel. This id may be used anywhere a uart component is required.
  • baud_rate (Required, int): The baud rate to use for the channel. This is optional for the stm32_vcp, esp_jtag and cdc_acm types.
  • buffer_size (Optional, int): The size of the buffer to use for the channel. Defaults to 256 bytes.
  • stop_bits (Optional, float): The number of stop bits to use. Defaults to 1. Other options are 1.5 and 2.
  • data_bits (Optional, int): The number of data bits to use in the range 5-8. Defaults to 8.
  • parity (Optional, string): The parity to use. One of NONE, EVEN, ODD, MARK and SPACE. Defaults to NONE.
  • dummy_receiver (Optional, boolean): If set to true, the channel will consume any data received. This is useful for debugging purposes. Defaults to false.
  • debug (Optional, boolean): If set to true, the channel will log all data sent and received. Defaults to false.
  • debug_prefix (Optional, string): A string prepended to every debug log line for this channel. Useful when multiple channels have debugging enabled, to distinguish their output in the log. Defaults to "".
  • flush_timeout (Optional, Time): The maximum time to wait for the USB output queue to drain when flush() is called. If the queue does not drain within this time, flush() returns a TIMEOUT result. Defaults to 100ms.

The cdc_acm type is a generic USB CDC ACM (Abstract Control Model) device. This is a common USB device class for serial communication. This driver does not strictly enforce the CDC-ACM configuration specification, so it may work with devices that do not properly implement that specification. It expects to find a single interrupt endpoint, a single bulk in endpoint, and a single bulk out endpoint.