I filled a bug report to Espresif (they offer a $2000 price for anyone who discover a bug in ESP modules, that is motivating blush) about those connectivity problems. After exchanging some emails and sending many wireshark packet captures, they suggested me to test the effect of WIFI_NONE_SLEEP, which actually worked. The problem is, they don’t recommend using this mode in which the wifi radio is always on, as the power consumption and heat increase a lot. In “normal” mode, the wifi radio wakes up every 100ms, wait for the router’s beacon for any packet pending to be received, and goes to sleep again. According to Espresif’s support, my Wifi network is “bad”, because 70% of the beacons are lost and that is the cause of the connectivity problem: there are packets (such as your ping tests) waiting but they are never received by the ESP due to the beacons being lost. That should be also the reason that WIFI_NONE_SLEEP solve the problem, as the wifi radio is always on and more beacons can be received. However, I don’t believe that a “bad” network is the problem. I have tested THREE routers so far, in different channels, and I live in a detached house with very little interferences from neighbour’s wifi networks. The ESP modules loss connectivity in all cases, even with a very strong signal from the router just one meter apart. It is a weird problem, and the router firmware and the sleep mode do have an influence, somehow.
Maybe i found one issue with the ESP. I have tried a lot of solutions to reduce the problem with jitter. Nothing seems to work, even the three commands
to reduce problems with interrupts didn't seem to work.
So what to do is reducing interrupts or the time interrupts need to complete.
The solution for me is to set the wifi.sleepMode to WIFI_NONE_SLEEP. The default value from the SDK is WIFI_MODEM_SLEEP, which will set the modem to sleep between two beacons from the ap. So if there is an interrupt from the wifi core to respond to the ap's beacon to hold the connection.
My idea is, that if the modem is in sleep mode, it needs much more time to wake up and respond to the beacon. So i disabled the sleep mode and the jitter got reduced, but you will have a higher power consumption.