Upload-and-monitor task problem with dtr and rts

I’ve got a standard uart setup with my esp32. RTS is connected to EN for resetting and DTR goes to the pin that specifies startup mode.

When I do an upload task from the vscode ide it works fine. I can then open the serial monitor and start my code but in order to do that I have to manually inactivate the DTR pin (raise it using ctrl T/D) and then inactivate the RTS (release the reset using CTRL T/R). This starts up my code.

This is a pain to do on every debug cycle. I thought the upload-and-monitor task would do what I wanted but it also leaves DTR and RTS activated and I still have to manually raise the pins.

Is there some way to specify that DTR and RTS should be turned off when the monitor starts so that my code can start? I will try to set up a macro but I doubt macros can trigger the ctrl-T commands.

Update: I set up espota (took 5 mins) and it works great but it didn’t do anything to help my serial monitor problem.

If I get the serial output showing in my monitor task and then run the upload task, when it finishes uploading it switches back to the monitor task and the restarts the monitor. I see the normal Executing task in folder ... platformio.exe device monitor and I’m back to the original RTS/DTR problem. I like that is switches to the monitor but I want it to just keep monitoring without resetting.

If I use an external terminal program everything works as it should. The terminal shows to ota happening and then shows the code running. But I would really like to use a serial monitor in the IDE, not externally.

How can I do an upload without the serial monitor restarting with RTS/DTR off?

Do the documented monitor_rts and monitor_dtr options help you here?

2 Likes

Ah. That should do it. I’m not familiar with monitor options but I’ll research it.

These options are not enough as they seem to toggle RTS (enable) THEN DTR (io0) which puts it in programming mode.

I can fully verify that. using monitor_rts and monitor_dtr doesn’t work for me as the order is wrong. The only way to get it running is to toogle it manually (Or is there a option to define in which order these monitor_XY options are read in (and processed?)

I tried this for my esp-c3-01m-kit and it works now fine!

monitor_speed = 115200
;ceci est nécessaire sinon, le esp est bloqué lorsqu’on ouvre le monitor
monitor_dtr = 0
monitor_rts = 0

1 Like

Super helpful! I’m trying to program AI Thinker ESP32-CAM on platform IO and initially couldn’t get it to work. The program runs at first, but as soon as the serial
monitor opens it stops running completely. And pressing the reset button doesn’t help.
The serial monitor doesn’t work either. I was very frustrated. Then I found someone mentioning setting dtr and rts to inactivated helps and I tried. It works! Then I found this comment, so I don’t have to press ctrl+T ctrl+D/R every time. And now everything is working. Great!