From 3f21bf93befd4df368c576d1eb47e243a49ea9d4 Mon Sep 17 00:00:00 2001 From: RoSchmi Date: Mon, 5 Apr 2021 12:12:24 +0200 Subject: [PATCH] Seems to work reliable --- include/config.h | 4 ++-- platformio.ini | 6 +++--- src/main.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/config.h b/include/config.h index 4dd7b6a..9df8470 100644 --- a/include/config.h +++ b/include/config.h @@ -22,7 +22,7 @@ // The credentials of your WiFi router and the name and key of your // Azure Storage Account have to be set in the file config_secret.h -#define SENDINTERVAL_MINUTES 2.0 // Sendinterval in minutes, in this interval data are sent to the Cloud +#define SENDINTERVAL_MINUTES 5.0 // Sendinterval in minutes, in this interval data are sent to the Cloud // is limited to be not below 1 second // Names for Tables in Azure Account, please obey rules for Azure Tablenames (e.g. no underscore allowed) @@ -53,7 +53,7 @@ // (Sensor readings are considered to be invalid if not successsfully // read within this timespan) -#define NTP_UPDATE_INTERVAL_MINUTES 20 // With this interval sytem time is updated via NTP +#define NTP_UPDATE_INTERVAL_MINUTES 14400 // With this interval sytem time is updated via NTP // with internet time (is limited to be not below 1 min) #define UPDATE_TIME_FROM_AZURE_RESPONSE 1 // 1 = yes, 0 = no. SystemTime is updated from the Post response from Azure. diff --git a/platformio.ini b/platformio.ini index 7fa0783..c17fbcc 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,9 +12,9 @@ platform = atmelsam board = seeed_wio_terminal framework = arduino -upload_protocol = jlink -upload_port = jlink -debug_tool = jlink +;upload_protocol = jlink +;upload_port = jlink +;debug_tool = jlink ;platform_packages = framework-arduino-samd-seeed@https://github.com/Seeed-Studio/ArduinoCore-samd.git platform_packages = framework-arduino-samd-seeed@https://github.com/Seeed-Studio/ArduinoCore-samd.git#v1.8.1 diff --git a/src/main.cpp b/src/main.cpp index 8eae174..3a486fe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -594,13 +594,12 @@ void loop() SAMCrashMonitor::iAmAlive(); #endif - // Update RTC from Ntp when ntpUpdateInterval has expired - if (((currentMillis - previousNtpUtdateMillis) >= ntpUpdateInterval) && ((currentMillis - previousNtpRequestMillis) >= 5000)) + // Update RTC from Ntp when ntpUpdateInterval has expired, retry after 20 sec if update was not successful + if (((currentMillis - previousNtpUtdateMillis) >= ntpUpdateInterval) && ((currentMillis - previousNtpRequestMillis) >= 20000)) { - previousNtpRequestMillis = currentMillis; dateTimeUTCNow = sysTime.getTime(); uint32_t actRtcTime = dateTimeUTCNow.secondstime(); - + int loopCtr = 0; unsigned long utcNtpTime = getNTPtime(); // Get NTP time, try up to 4 times while ((loopCtr < 4) && utcTime == 0) @@ -608,6 +607,7 @@ void loop() loopCtr++; utcTime = getNTPtime(); } + previousNtpRequestMillis = currentMillis; if (utcNtpTime != 0 ) // if NTP request was successful --> synchronize RTC {