Serial monitor displays good data when I start it before rebooting ESP32 board. Stop/Start Monitoring sequence produces corrupt data most of the time and occasionally freezes the program on ESP32 board. Here is an example of “normal” corrupted data followed by a case, which froze the program on ESP32:
---- Closed the serial port /dev/ttyACM0 ----
---- Opened the serial port /dev/ttyACM0 ----
�'� #��'�`#��'� b�
---- Closed the serial port /dev/ttyACM0 ----
---- Opened the serial port /dev/ttyACM0 ----
## $$$$$$d$$$d$$$d$$$$l$$$d$$$$$$$$l$$$d$$$$$$$$$$$$$$$$l$$$$$$$$l$$$$l$$$d$$$$l$$$d$$$$l$$$l$$$$$$$$l$$$$$$$$d$$$$$$$$l$$$d$$
Is there a solution to this problem? I’m testing a different device without convenient access to reboot or power cycling.
On some Linux distributions, certain installed programmes like brltty or modem manager can also interfere with serial ports. Make sure they’re removed (some come auto-installed with the distribution).
I tested on Raspberry Pi with the most current OS and fresh installation of VSCode and PlatformIO. Behavior is essentially the same, except of a single instance of a corrupt stream turning into a valid one.
I also noticed that my Ubuntu setup has two serial monitors. I have VSCode extension for Arduino installed there, but disabled for these tests. Here is the PlatformIO being used:
I went for something completely different and repeated this test with Seeeduino Xiao SAMD. No problems at all with starting and stopping serial monitor, both with PlatformIO and Arduino. I will test a few other ESP32 boards. Perhaps the serial to USB chip on DOIT ESP32 DEV KIT v1 board, i.e. CH9201X, is causing the problem. I selected this chip, because it is supposed to automatically go to the low power state when USB is not being used.
I tested a few different ESP32 boards with QinHeng Electronics CH340 serial to USB chip. No problems with corrupted data. It seems that behavior of CH9201X (1a86:55d4 QinHeng Electronics USB Single Serial) is the source of this problem.