Closed gromgit closed 3 years ago
Forgot to mention: I also ran the sample code in this project's README (https://github.com/adafruit/Adafruit_CircuitPython_NTP/blob/master/README.rst), and it also returns epoch times that are 1 hour ahead of real time.
Apologies, it turned out to be a false alarm. I just noticed the following in the code I posted:
ntp.set_time(60 * 60)
:man_facepalming:
the timezone setting in secrets.py appears to have no effect, so local time = UTC
The timezone in secrets.py is used for the Adafruit IO time service in the PyPortal library (https://github.com/adafruit/Adafruit_CircuitPython_PyPortal), not this library.
the "UTC" retrieved via NTP is somehow 1 hour ahead of actual time
I'm not exactly sure what's causing the error, but I'd like to find out.
It likely wouldn't be a bug in CircuitPython - this library sends a command to the ESP32, running nina-fw, and is handled by the getTime
method in nina-fw (https://github.com/adafruit/nina-fw/blob/master/main/CommandHandler.cpp#L809). I believe this uses the ESP32 SNTP which queries pool.ntp.org
.
Yeah, the bug turned out to be in the code I copied. I'm not sure why running the NTP example code after I discovered the issue still returned the incorrect epoch, but since an overnight power-cycle seems to have made that problem go away, I think I'm good.
I just installed CircuitPython v5.3.1 on my PyPortal Pynt, and updated the
lib
directory on the Pynt with the corresponding files/dirs fromadafruit-circuitpython-bundle-5.x-mpy-20201010.zip
, so everything's as up-to-date as reasonable.I then installed the following
secrets.py
:and the following simple clock
code.py
, based on https://github.com/imekon/weather-clock :The code runs correctly, but the time displayed is exactly 7 hours behind my local time, despite my double-checking the
timezone
setting insecrets.py
. Also, I confirmed that the epoch time displayed on the Pynt is exactly 1 hour (3,600 seconds) ahead of the corresponding epoch on my Linux box.Therefore, two things seem to be going wrong:
timezone
setting insecrets.py
appears to have no effect, so local time = UTCAm I doing something wrong in the code, or are these bugs in CircuitPython and/or its libraries?