Serial Monitor crashes after startup of ESP32

Hi,
I’m using PlatformIO on VS Code (Windows) to upload and test code on a ESP32-CAM module.
To upload and to use the serial monitor I’m using an USB-to-TTL converter.

Compiling and uploading works perfect.
However the serial monitor crashes after startup/restart of the ESP32.

Here is the output of the serial monitor:

> Executing task in folder ESP32-Cam-Webserver: C:\Users\claus\.platformio\penv\Scripts\pio.exe device monitor <

--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
--- Miniterm on COM3  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac

Exception in thread rx:
Traceback (most recent call last):
  File "C:\Users\claus\.platformio\python3\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\Users\claus\.platformio\python3\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "c:\users\claus\.platformio\penv\lib\site-packages\serial\tools\miniterm.py", line 445, in reader     
    data = self.serial.read(self.serial.in_waiting or 1)
  File "c:\users\claus\.platformio\penv\lib\site-packages\serial\serialwin32.py", line 257, in in_waiting    
    raise SerialException("ClearCommError failed ({!r})".format(ctypes.WinError()))
serial.serialutil.SerialException: ClearCommError failed (PermissionError(13, 'Zugriff verweigert', None, 5))

According to python 3.x - Read/Write value for some time,pyserial throws ClearCommError failed (PermissionError(13, 'Access denied', None, 5) - Stack Overflow and call to ClearCommError Failed this may be a hardware problem with the adapter or a software problem.

What I find interesting is that the bootloader messages appear fine, but as soon as it boots into your application code, the connection is being closed, presumably by the USB-TTL adapter.

  • What code are you uploading to the ESP32?
  • Which exact adapter are you using?
  • Can you try different ones if available?
  • Does the same error occur when using a blinky sketch?
  • Does your application attempt to drive GPIO pins which are connected to the USB-serial adapter, causing it to fail / detect a conflict and to close the connection?
  • Does the same occur when uploading the sketch via the Arduino IDE?