Lornioiz wrote:weldeng wrote:
I am running a timer program on the ESP8266. Because the rtc is losing about 20 minutes/day I am calling setttime() every hour. I can't make it a day before I get the error shown below, which then stops the program from continuing to run. Is there a way to ignore an error like this so the program can continue to run
OSError: [Errno 110] ETIMEDOUT
Can I ask you how do you do the hourly polling? Do you have a variable holding the elapsed time or do you use a less resource intensive method (if it exist at all).
In Python (i.e. with hardware unlimited resources) I would use that approach, but I'm curious to know if there is a better solution.
Here is how I am doing it. Note the indents are not showing when I cut and paste:
while True:
year, month, day, hour, minute, second, ms, dayinyear = utime.localtime()
# adjust hour for time zone below
if hour >= 5:
hour = hour-5
if hour < 5:
hour = hour +19
# hourly time correction
if hour != oldhour:
try:
settime() # reset real time clock(it looses up to about 3 minutes/hour)
except:
print ('error connecting, will try to adjust RTC in 60 minutes')
pass
oldhour = hour