esp8266 - yield() can crash the device. Suggestion included.
cr1st1p opened this issue · 1 comments
-
Arduino board: Lolin nodemcuv3 esp8266
-
Arduino IDE version: eclipse, project compiled by 'platformio'.
-
List the steps to reproduce the problem below: run a read of the sensors during a handler of ESPAsyncWebServer
Arduino version: 2.5.2
Result: when trying to read the sensor data (DHT11 and DHT22) from a web handler for ESPAsyncWebServer, device gets a panic and then reboots .
The panic is from the implementation of 'yield', i.e. somehow, while in the ESPAsyncWebServer response handler, we're already in some special context.
One fix would be to have the code from yield() but without the panic(). So either that, or, an alternative, is to call optimistic_yield(5000);
Both variants stopped the crash for me.
Code gave me timeout waiting for high pulse, and after digging, found out that during execution of a callback for ESPAsyncWebServer, you can not use yield and... delay() - which made the initial low pulse too short.
So I actually have a bigger problem to solve, meanwhile it means that even if we replace the yield() with a more relaxed version, reading data will not work anyway.
Feel free to close this. Thank you for your time!