Question: Ping ESP32C3 is bad after hard reboot, but good after soft reboot #12462
-
Hi guys, I hope you have one or maybe more ideas for my issue with my ESP32C3 project. I've experimented with an automated reboot after a hard reset with sys.exit(), without success. The esp is running micropython 1.20-379-ga18d62e06, a nightly built and flashed some weeks ago. This is basically the code I am executing (stripped down to the very basics, I have omitted content of variables): import network # type:ignore
import Microdot
if __name__ == "__main__":
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.disconnect()
wlan.config(hostname="esp32")
wlan.connect(str.encode("x"), str.encode("y"))
while not wlan.isconnected():
sleep(1)
app = Microdot()
app.run(host="address is set", port="port is set", debug=True) There is some async code involved during bootup, which is not shown here, but I have tried to do everything synchronously without any other effect than the already described one. I have the suspicion the WIFI module is involved somehow, because the ping is still working after pressing CTRL+C 😮 while being connected with Thonny. The ping response is important for my client application to know that in general the server is kind of "available". |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Maybe, try: while not wlan.isconnected():
sleep(1)
print (f'network config: {wlan.ifconfig()}') |
Beta Was this translation helpful? Give feedback.
-
What is the power management mode of your STA? You can try turning it off completely and see how it works for you.
|
Beta Was this translation helpful? Give feedback.
-
Soft reset does not reset the wifi subsystem, hard reset does. One advantage is that after a soft reset, connecting is usually much faster. To reset the wifi subsystem try |
Beta Was this translation helpful? Give feedback.
-
Doing this at the beginning of my connect sequence seems to be more reliable: if sta_if.isconnected():
sta_if.disconnect()
print ('started in the connected state, but now disconnected')
else:
print ('started in the disconnected state') Or try glenn20's wifi.py def disconnect():
_sta.disconnect()
wait_for(lambda: not _sta.isconnected(), 5)
_sta.active(False) # added |
Beta Was this translation helpful? Give feedback.
What is the power management mode of your STA?
You can try turning it off completely and see how it works for you.