On ESP32-S2/S3 (and ESP32-C3/C6 for USB CDC) the native USB port can be used by ESP3D in two different ways, depending on what is connected to it:
| Mode | ESP role | Connected to | Feature |
|---|---|---|---|
| USB Serial OTG | USB host | 3D printer / CNC USB port | USB_SERIAL_FEATURE |
| USB CDC | USB device | Computer | USB_CDC_CLIENT_FEATURE |
The two modes cannot be used at the same time.
USB Serial OTG
Section titled “USB Serial OTG”On ESP32-S2 and ESP32-S3 the USB Serial OTG can be enabled. This allows to connect the USB OTG port to the 3D printer/CNC usb port if this one has Silicon Labs CP210x, FTDI FT23x or CP34x USB to UART converter.
See Module client for implementation details.
USB CDC
Section titled “USB CDC”The native USB port of the ESP32-S2/S3/C3/C6 is used as serial port (USB CDC device), like on the Wemos S2 mini or the Waveshare ESP32-S3-Touch-LCD-1.47. A computer connected to this USB port can send ESP3D commands and receive the printer/CNC output, like a serial terminal. The printer/CNC is then connected to the UART of the board.
Configuration
Section titled “Configuration”USB_CDC_CLIENT_FEATUREinconfiguration.h- the board must be built with
ARDUINO_USB_CDC_ON_BOOT=1, thenSerialis the native USB and the UART0 isSerial0 - it cannot be used with
USB_SERIAL_FEATURE
The client is enabled by default, it can be enabled / disabled with [ESP935] or by the setting service/usb_cdc/enable of [ESP401].
The USB port itself is never stopped, because it is also used by log output and to flash the board, only the client is stopped.
Log output
Section titled “Log output”The log can use the native USB port with LOG_OUTPUT_USB_CDC in configuration.h, it also needs ARDUINO_USB_CDC_ON_BOOT=1.
LOG_USB_CDC_WAIT_MS can be defined to wait up to x ms at boot for the host to open the port, so the first logs are not lost.
See Module client for the client behavior.