From 83d77277e79d549941ac19b13e569777bd2e1c01 Mon Sep 17 00:00:00 2001 From: arofarn Date: Wed, 22 Apr 2020 11:10:11 +0200 Subject: [PATCH] Add NTP check every hour (ESP8266 RTC is BAD at keeping track of time) --- code/main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/code/main.py b/code/main.py index 5390cea..6d6ead5 100644 --- a/code/main.py +++ b/code/main.py @@ -239,3 +239,10 @@ while True: if BRIGHTN_DATA is not None and time.ticks_diff(time.ticks_ms(), MQTT_TIMER) >= 0: MqttMultiPublish(BRIGHTN_DATA) BRIGHTN_DATA = None + + time_to_test = rtc.datetime() + + if time_to_test[5] + time_to_test[6] == 0: # (chaque heure quand min et sec = 0) + print("Old Time: {0:04d}/{1:02d}/{2:02d}_{4:02d}:{5:02d}:{6:02d}.{7}".format(*time_to_test)) + set_rtc() + print("Time set: {0:04d}/{1:02d}/{2:02d}_{4:02d}:{5:02d}:{6:02d}.{7}".format(*rtc.datetime()))