Device time is incorrect after power cycle

I’m having a similar issue to this question with an Imp001: Time() returning incorrect value after power cycle

While running the code from this example (A Power Efficient Refrigerator Monitor | Dev Center) the timestamp of the first reading is always Jan 1, 2000 if it starts from a cold boot after a power cycle. As mentioned in the post above, “The imp’s RTC time will be synced shortly after connecting.” But in practice, all the modifications I’ve tried to force a server connection prior to taking a reading have failed to update the time. Is there some method or pattern that will reliably force the time to be updated?

Like I said a couple of years ago, a power cycle will clear the clock. The imp will be adjusted to the correct time shortly after a connection is made. I deal with this in my code by testing the time value after a restart, setting a flag when I have determined that the time has been synchronised. If your imp cold starts and cannot get a connection, it could run without an accurate clock for an extended period until it finally connects.

Ok, so it sounds like there isn’t an imp api method I can use to sync the clock. Out of curiosity what’s your approach to validating the time?

I know this involves buying a module and adding cost/parts, but I have been using these from AliExpress: DS1302 real time clock module

Works great and always remembers date and time. Uses the I2C pins.

This topic was automatically closed after 60 days. New replies are no longer allowed.