Table of Contents
Serial USB Connection
KVM Virtual Machine USB
ESP32 development environment is running inside Virtual Machine. To forward the USB port to the VM do the following steps in Virtual Machine Manager on the host:
- Connect the ESP32 board to the PC using the USB cable.
- Select Virtual Machine –> Redirect USB device
- Select Silicon Labs CP2102 USB or similar. A WROOM-32U is recognized as a CP210x: CP210x USB to UART Bridge.
Check USB device in client
Check if the USB port is not recognized within the Virtual Machine:
# lsusb ------- Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 003: ID 10c4:ea60 Silicon Labs CP210x UART Bridge Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU Tablet Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Find USB Port used
When plugged in ESP boards might use different tty ports, based upon the UART chipset and driver used. Some examples:
- original ESP32-Devkit-WROOM –> /dev/ttyUSB0
- ESP32-C3 mini –> /dev/ttyACM0
There are 2 methods to figure out the actually used USB port.
Method 1: via udevadm
To find out which port is used, run the following command:
sudo udevadm monitor -u
Then unplug/plug the ESP32 board (enabling/disabling via Redirect USB device). This changes show the following output. In this case indicating that the used port is /ttyUSB0.
UDEV [2304.408314] add /devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-3 (usb) UDEV [2304.408372] add /devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-3/1-3:1.0 (usb) UDEV [2304.417209] add /devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-3/1-3:1.0/ttyUSB0 (usb-serial) UDEV [2304.423267] add /devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-3/1-3:1.0/ttyUSB0/tty/ttyUSB0 (tty) UDEV [2304.431423] bind /devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-3/1-3:1.0/ttyUSB0 (usb-serial) UDEV [2304.433667] bind /devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-3/1-3:1.0 (usb) UDEV [2304.433728] bind /devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-3 (usb)
Method 2: via /dev/tty
To check the device name for the serial port of your ESP32 board (or external converter dongle), run this command two times, first with the board / dongle unplugged, then with plugged in. The port which appears the second time is the one you need:
ls /dev/tty*
Adding user to dialout
The currently logged user should have read and write access the serial port over USB. On most Linux distributions, this is done by adding the user to dialout group with the following command:
sudo usermod -a -G dialout $USER
Connect with Miniterm
Connect to the ESP with the miniterm that is part of the ESP-IDF installation. The used terminal emulator is:
~/development/esp32/idf-tools/python_env/idf6.1_py3.13_env/bin/pyserial-miniterm
Various examples with different ports and speed:
~/development/esp32/idf-tools/python_env/idf6.1_py3.13_env/bin/pyserial-miniterm /dev/ttyUSB0 74880 ~/development/esp32/idf-tools/python_env/idf6.1_py3.13_env/bin/pyserial-miniterm /dev/ttyUSB1 74880 ~/development/esp32/idf-tools/python_env/idf6.1_py3.13_env/bin/pyserial-miniterm /dev/ttyUSB0 115200 ~/development/esp32/idf-tools/python_env/idf6.1_py3.13_env/bin/pyserial-miniterm /dev/ttyUSB1 115200
