Skip to content

Commit

Permalink
Seems to work reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
RoSchmi committed Apr 5, 2021
1 parent 4185dcd commit 3f21bf9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,20 +594,20 @@ 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)
{
loopCtr++;
utcTime = getNTPtime();
}
previousNtpRequestMillis = currentMillis;

if (utcNtpTime != 0 ) // if NTP request was successful --> synchronize RTC
{
Expand Down

0 comments on commit 3f21bf9

Please sign in to comment.