Communicate to PC via USB-CDC connection

Hello everyone,

I’m using an ESP32-DOIT-DEVKIT-V1 and have successfully connected it to my PC. When I do so, a serial port shows up in my device manager (for example, as COM9).

I’m wondering how to configure the YAML file in ESPhome to set up UART communication between my ESP32 and PC. Essentially, I’d like to exchange data between the two using the UART interface.

Has anyone done this before or can point me in the right direction for the YAML configuration?

Thanks in advance for your help!

Also I believe if you are using the USB as a UART for custom sensors, you need to turn off serial logging in the ESPHome Logger component:

  • baud_rate (Optional, int): The baud rate to use for the serial UART port. Defaults to 115200. Set to 0 to disable logging via UART.

The link you mentioned contains next lines:
id: uart_bus
tx_pin: D0
rx_pin: D1
baud_rate: 9600

What do I have to enter in the pins (bold) when I want to communicate via USB-CDC?

Thanks in advance

I believe UART0 is by default on pins GPIO1(TX0) and GPIO3(RX0) of the ESP32.

Is UART0 equal to the USB-CDC connection?

I believe so - but I’m just basing that on Google - so all you can do is try it.

Edit: looking again, this is for logger, so may not be relevant.

Looks like you need to configure the hardware UART. Although that doesn’t appear to be available for your board.

  • hardware_uart (Optional, string): The Hardware UART to use for logging. Defaults to UART0.

  • USB_CDC - uses the USB CDC driver (Only on ESP32S2 and ESP32S3)

1 Like