Page 1 of 1

[solved] ESP32 resets when using python Serial library

Posted: Tue Aug 15, 2023 9:25 am
by natdf2d
Hello,

I am trying to use python library to read/write to serial of ESP. The interface is initialized as below, however ESP32 resets when I run the code. How can I fix this? I am running the code on Windows PC. Many thanks!
ser = serial.Serial(
port = com_port,\
baudrate = baud_rate,\
parity=serial.PARITY_NONE,\
stopbits=serial.STOPBITS_ONE,\
bytesize=serial.EIGHTBITS,\
dsrdtr=0,\
rtscts=0,\
xonxoff =1,\
timeout=2)

Re: ESP32 resets when using python Serial library

Posted: Wed Aug 16, 2023 3:28 pm
by MicroController
https://stackoverflow.com/a/68914329
"You need to set RTS and DTR to False before opening the port"

Re: ESP32 resets when using python Serial library

Posted: Thu Aug 17, 2023 7:50 am
by natdf2d
Hi, yes, I also tried that:
ser = serial.Serial(
port = com_port,\
baudrate = baud_rate,\
parity=serial.PARITY_NONE,\
stopbits=serial.STOPBITS_ONE,\
bytesize=serial.EIGHTBITS,\
timeout=2,\
dsrdtr=False,\
rtscts=False)
Still the same behavior.
I also tried this https://heepy.net/index.php/Prevent_win ... trol_lines but also no improvement.

Re: ESP32 resets when using python Serial library

Posted: Thu Aug 17, 2023 10:17 am
by MicroController
natdf2d wrote:
Thu Aug 17, 2023 7:50 am
Hi, yes, I also tried that:
...
No, you didn't. dsrdtr=False and rtscts=False is not what ser.setDTR(False) and ser.setRTS(False) do.

Re: ESP32 resets when using python Serial library

Posted: Thu Aug 17, 2023 11:09 am
by natdf2d
Just tried, thanks so much, that does seem to work. I thought that setting dsrdtr=False is the same as ser.setDTR(False), my bad. Appreciate your help!