I have encountered a strange condition when attempting to sync time: one Electron does not sync correctly – I get a November 30, 1968 date from the cloud, but all other functions appear to work correctly. But when I run the same code on a different Electron, I get the correct date and time and everything functions as expected.
The code in question is:
void setup()
{
Serial.begin(57600); // Begin the Serial interface
Serial.print (F("Hidrosonico online. Version "));
Serial.println (VERSION);
pinMode (PULSEPIN, INPUT); // Sonar pulse width pin
if (Particle.connected() == true)
{
Serial.println(F("Connected to Particle Cloud."));
}
else
{
Serial.println(F("Not connected to Particle Cloud."));
}
unsigned int timeout = millis() + timeoutInterval;
while (Time.year() <= 1970 && millis() <= timeout)
{
Particle.syncTime();
}
if (Time.year() <= 1970)
{
Serial.println(F("syncTime timed out; time is wrong."));
}
Particle.publish ("startup", VERSION, PRIVATE);
Time.zone (UTCOFFSET); // Set the local time zone
Serial.println (Time.timeStr()); // Print the time to Serial for confirmation
Cellular.off(); // Turn the GSM module off to save power
RGB.control (true); // Take control of the LED
RGB.color (0, 0, 0); // Shut off the LED to save power
Serial.println(F("Setup complete."));
}
This seemed to start happening at about the same time that the malfunctioning unit went over 1MB usage, though I cannot say whether this is related.
Any insights welcomed.