ntptime.settime() does not work correctly (Raspberry Pico W) #10611
Replies: 7 comments 5 replies
-
When I had some issues on the ESP32 settime() Peter Hinch added the test at the top. def settime():
t = time()
if t < 0:
return False
tm = utime.gmtime(t)
machine.RTC().datetime((tm[0], tm[1], tm[2], tm[6] + 1, tm[3], tm[4], tm[5], 0)) I thought that this change got placed in the code, but not according to: |
Beta Was this translation helpful? Give feedback.
-
Thanks for the help. Also, when the call to the ntptime.settime() function is tested, the program terminates. No error code is output. If the pico is not connected, error -6 comes immediately. ... Output: |
Beta Was this translation helpful? Give feedback.
-
Thanks for pointing out the polling frequency according to RFC4430. The behavior of my test program with 2 seconds polling interval would be explained. |
Beta Was this translation helpful? Give feedback.
-
It's worth being aware that WiFi links aren't necessarily stable over long periods as discussed in my unofficial FAQ. Laptops and tablets have an OS which does a good job of hiding brief outages from the user. Microcontrollers don't have that, and it's your job to maintain connectivity. |
Beta Was this translation helpful? Give feedback.
-
The problem has been solved. After updating the time every 5 minutes for two days, a connection problem was detected. In my test program I had caught the function ntptime.settime(). I had not done that before in my program. my test program: ...initialization WLAN once this error occurred: |
Beta Was this translation helpful? Give feedback.
-
The behaviour of I wrote this version a while ago which addresses some of these issues and also has rudimentary localtime support. |
Beta Was this translation helpful? Give feedback.
-
There are no more crashes since using ntptime.settime() over TRY. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In one application, I have the time updated once a day via NTP. After a few days the program crashes. I found out that the call ntptime.settime() is the cause. If I synchronize the time in a loop every two seconds, I get an overflow after a few minutes.
Test program:
import time, ntptime
z = 0
while(True):
ntptime.settime()
time.sleep(2)
z=z+1
print(str("ok"), z)
Error output:
ok 114
ok 115
ok 116
ok 117
Traceback (most recent call last):
File "", line 4, in
File "ntptime.py", line 1, in settime
OverflowError: overflow converting long int to machine word
Is it possible that there is an error in the called function?
Translated with www.DeepL.com/Translator (free version)
Beta Was this translation helpful? Give feedback.
All reactions