0

I am looking for an easy way to schedule a daily reboot of my ESP8266, currently running on Micropython. I did a fair amount of research and haven't find anything that I can use/understand. I m wondering if this need to be done through Micropython or another system language. Worst case scenario I ll create an infinite loop that check for the time of the day but that seems very extreme and not a best use of the RAM. The reason behind the reboot is the controller is going to be unattended for long period of time and I need it to reset daily in case it crashes so I don't go longer than 24 hours without the data it is currently providing.

I have looked at uasyncio but don't understand it.

2 Answers2

0

According to the docs, you can use the watchdog timer machine.WDT. However this forum discussion suggests that the current ESP8266 Micropython doesn't actually do what the docs say it does:

OK, so it seems that the watchdog is not fully implemented on the esp8266 as it is used internally.

It appears that all you can do is trigger it by disabling interrupts, not sure how useful that would be.

Normally you would configure the watchdog with your chosen timeout then make sure your code calls its feed method at a shorter interval than the timeout setting. If your code has crashed and the timeout expires, the watchdog resets the system. It sounds as if this isn't fully implemented on the ESP8266 version at the moment.

You may find more information and workarounds on the Micropython forum, and if not you'll probably get a better response to any questions there.

nekomatic
  • 5,988
  • 1
  • 20
  • 27
0

First, you should decide which timer to use, following are cons;
loop - "sleep" from timelib stops execution of current thread
millis - "time" or "ticks_ms" from timelib are fine, but you have to know how to overcome millis cycle

#as micropython lib
import utime as time

secs = time.time()
print (secs) #sec

millis = time.ticks_ms()
print (millis) #ms

rtc - rtc modul needed
web - php timer via wifi necessary
system - private wifi necessary, external comp has to be allways on
gps - gps modul and signal needed

Second, choose one timer and just hang up the reboot on it by specifying of certain time, then arrange reset:

#either hard reset, like power off-on
import machine
machine.reset()

#or soft reset
import sys
sys.exit()

Third, finally set time shift to get start of next reboot beyond current action, otherwise reboots shall be repeated till time zone, you specified, shall pass.

Johny English
  • 166
  • 3
  • 6