ESP32 program completely halts when serial terminal is disconnected

totesnochill
Posts: 3
Joined: Thu Nov 17, 2022 3:07 am

ESP32 program completely halts when serial terminal is disconnected

Postby totesnochill » Mon May 15, 2023 12:53 pm

My platform is ESP32-wroom (Devkit v1 board). ESP-IDF 5.0 on Win10.

I've been using PuTTY to monitor the ESP32's serial log and output (the main serial where all the diagnostic info goes, not the optional ones). It worked just fine.

However, today I've noticed that upon closing PuTTY's terminal window (and clicking "ok" when it asks "Are you sure you want to close the session?") the ESP32 comes to a complete halt. The program running on it stops. Power, however, is still on.
Using ESP-IDF's VSCode extension "monitor" function does not cause this effect, however.

I've tried flashing the official blink example to see if the problem was in my code. But nope, the LED stops blinking the moment I disconnect the PuTTY terminal session. What may be the reason?

P.S: I'm aware that ESP32 may use RTS/DTS pins of the serial for some internal controls, i.e. every time serial connection is established, ESP32 soft-resets. Is that the case here too? I.e. maybe PuTTY sends some signal over serial that ESP32 interprets as "halt"?

Steps to recreate this:
1.Flash official blink example, connect an LED to a chosen pin.Confirm that the led blinks.
2. Connect to ESP32 with PuTTY (115200baud serial)
3. Close the PuTTY terminal window by clicking on the X then "Ok"
4. LED will stop blinking.

MicroController
Posts: 1743
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP32 program completely halts when serial terminal is disconnected

Postby MicroController » Mon May 15, 2023 5:38 pm

P.S: I'm aware that ESP32 may use RTS/DTS pins of the serial for some internal controls, i.e. every time serial connection is established, ESP32 soft-resets. Is that the case here too? I.e. maybe PuTTY sends some signal over serial that ESP32 interprets as "halt"?
That may definitely be the culprit here. The ESP is powered down by setting RTS = low and DTR = high. If these are the signal levels that PuTTY sets upon closing the connection, the ESP is kept in reset/powered down. Try setting PuTTY's serial flow control settings to "none" to see if it still messes with the RTS/DTR lines then.

totesnochill
Posts: 3
Joined: Thu Nov 17, 2022 3:07 am

Re: ESP32 program completely halts when serial terminal is disconnected

Postby totesnochill » Tue May 16, 2023 9:39 am

Yeah, it seems to be the case from what I could find from other sources too. I've always had PuTTY set to "none" for flow control, but it still sends DTR/RTS signals on closing the connection. Might be the limitation of the software itself. Are there any terminal emulators/serial monitors that can close the connection without sending DTR/RTS?

MicroController
Posts: 1743
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP32 program completely halts when serial terminal is disconnected

Postby MicroController » Wed May 17, 2023 9:37 am

Give Yet Another Terminal (YAT) a shot. You can manually control RTS (a.k.a. RFR) and DTR (by clicking on the RFR or DTR labels/"lights" in the status bar) and even exiting and re-starting the application lets an ESP32-C3 keep running.

Who is online

Users browsing this forum: No registered users and 64 guests