Particle Argon Time Sync with Cloud

I tried to sync time from Particle cloud in fully manual system mode but I am getting wrong data and time as 01-01-2000. I attached my sample code below. Kindly suggest the correct and efficient way

SYSTEM_MODE(MANUAL);

SerialLogHandler logHandler(LOG_LEVEL_TRACE);

void setup() {
  (void)logHandler; // Does nothing, just to eliminate warning for unused variable
  Particle.connect();
  Particle.syncTime();
  waitUntil(Particle.syncTimeDone);
  Particle.disconnect();
}

void loop() {
  time_t time = Time.now();
  Log.info("Time is: %d", (int) time);
  Serial.println(Time.format(time, TIME_FORMAT_ISO8601_FULL));
  delay(7000);
}

Have you tried waiting for Time.isValid() rather than Particle.syncTimeDone() before connecting from the cloud?

1 Like

Sure let me try this

Thanks for the guidance. It is working fine now

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.