I'm trying to reference a stepper axis......but keep getting "soft wdt reset error" when I use the below code. Figured it is to do with the while function...….but battling to solve it ?
board is a D1 mini. Would appreciate any suggestions.....this is driving me nuts
I would suggest you post all your code and use code tags. And while you are at it take some time to read the how to use this forum sticky at the start of each forum section.
The code that drives the WiFi section on an ESP8266 has to be called every....I'm not sure...every few milliseconds otherwise you get the resets. If you have a while loop that goes on for a long time you will get resets. You need to rewrite without the while loop and let loop do the looping, that's what it's for.
And in answer to your next question there is already enough information on this website in tutorials and answers to similar questions about how to do that. Do some searching for non blocking code and doing several things at the same time.
horace:
using the ESP8266 in while() loops etc I found calling
ESP.wdtFeed();
to reset the watchdog timer helps
In that case why not just call yield();which does not only reset the wdt, but also executes any scheduled tasks, making you wifi connection much more reliable.
The wdt reboots the ESP when it hasn't been fed for 2.5secs. delay() calls yield(), and at the end of loop() also yield() is called.
the while loop is dependent on the the result of the analogRead(), but as before if the whole process takes more than 2.5s a wdt-reset will occur. Just add yield(); or possibly add yield() to the stepper library's run() function. Most stepper libraries aren't very good and depend on blocking code, but so far i haven't seen anyone making a proper effort to use timers to do the work. It must be out there though.
Deva,
++ Karma; // I missed the bit about stepper motor libraries being blocking, probably because I have never used one. Very annoying when I spend a lot of time on here trying to introduce newbies to non blocking code only to find libraries that are blocking.