-->
Page 1 of 2

NODEMCU ESP8266 - drop WiFi connection using analogRead(A0)

PostPosted: Thu Nov 12, 2020 6:50 am
by Carloroma63
Hi all,
this is my first post in this forum, can you tell me if is needed some presentation?
In meantime, I submit you this problem:

I've a NODEMCU ESP-12E and using Arduino IDE to develop on it.

I've found an issue that cause continue drop in Wifi connection. In my sketch I was using a analgRead(A0) in loop() function, without any timing. This cause the issue.

If I put a delay(200) in loop(), issue is not present.

Thanks

Carlo

Re: NODEMCU ESP8266 - drop WiFi connection using analogRead(

PostPosted: Sat Nov 14, 2020 4:04 am
by schufti
loops in esp8266 can be critical. If you don't use commands that "feed the watchdog" you may encounter strange things. Usually it is enough to put a "yield()" into the loop to keep all background tasks (as wifi) going and the watchdog happy. Unfortunately it brings some unacountable delay into your loop.

Re: NODEMCU ESP8266 - drop WiFi connection using analogRead(

PostPosted: Sat Nov 14, 2020 6:12 pm
by Carloroma63
schufti wrote:loops in esp8266 can be critical. If you don't use commands that "feed the watchdog" you may encounter strange things. Usually it is enough to put a "yield()" into the loop to keep all background tasks (as wifi) going and the watchdog happy. Unfortunately it brings some unacountable delay into your loop.
Right, but watchdog in not feeded, to use your example, each time loop() ends and restart? I known the need to use yeld() inside a "long time while-do " loop to avoid WDT reset, but I also known that yield() is implicit in loop() function, or not?

Re: NODEMCU ESP8266 - drop WiFi connection using analogRead(

PostPosted: Sun Nov 15, 2020 2:40 am
by JurajA
the same ADC is used by WiFi to test the signal level. hard use of analogRead(A0) influences the readings of the WiFi RD level. don't read A0 every loop