[solved] ESP32 resets when using python Serial library

natdf2d
Posts: 3
Joined: Tue Aug 15, 2023 9:22 am

[solved] ESP32 resets when using python Serial library

Postby natdf2d » Tue Aug 15, 2023 9:25 am

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)
Last edited by natdf2d on Thu Aug 17, 2023 11:11 am, edited 1 time in total.

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

Re: ESP32 resets when using python Serial library

Postby MicroController » Wed Aug 16, 2023 3:28 pm

https://stackoverflow.com/a/68914329
"You need to set RTS and DTR to False before opening the port"

natdf2d
Posts: 3
Joined: Tue Aug 15, 2023 9:22 am

Re: ESP32 resets when using python Serial library

Postby natdf2d » Thu Aug 17, 2023 7:50 am

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.

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

Re: ESP32 resets when using python Serial library

Postby MicroController » Thu Aug 17, 2023 10:17 am

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.

natdf2d
Posts: 3
Joined: Tue Aug 15, 2023 9:22 am

Re: ESP32 resets when using python Serial library

Postby natdf2d » Thu Aug 17, 2023 11:09 am

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!

Who is online

Users browsing this forum: Baidu [Spider] and 110 guests