Electron's RTC and time sync questions

I’d like to keep my electron’s RTC running through deep sleep. Is this possible to use something like a small CR2032 battery? The datasheet indicates that VBAT is for this purpose.

If you wish to power is via an external supply, you’ll need to remove this resistor. Instructions to remove this resistor can be found here

There are no such instructions for removing this resistor (at least that I can find).

As a side question: my work-around is to connect to the cloud which I thought synchronized the clock upon handshake, but it doesn’t seem to be that simple. If I try the following (in SEMI_AUTOMATIC mode):

Particle.connect();
waitUntil(Particle.connected);
Serial.println(Time.timeStr());
Particle.disconnect();

It returns the wrong time prior to disconnecting. My guess is that it needs a moment to sync, but how do I know when and if this has happened? I added a 3 second delay after waitUntil(Particle.connected) but this still wasn’t giving me the right time. I’ve settled on the following code which seems to consistently work but I’m hoping there is a more succinct and reliable way for doing this:

Particle.connect();
waitUntil(Particle.connected);
Serial.println("Time function running now...");
delay(3000);
Particle.syncTime();
delay(3000);

Thanks for any feedback.

Hi @LloydChristmas

In semi-auto mode you are in charge, so I think you need to call Particle.syncTime() after you are connected to make sure that it syncs. It is usual to wait until the time changes to something rational after starting the sync, since that occurs asynchronously. There are also Particle.syncTimeDone, Particle.syncTimePending and Particle.timeSyncedLast but I don’t think those are doc’ed yet and I’m not sure which release they are coming in. But the problem will be fixed soon.

https://docs.particle.io/reference/firmware/electron/#particle-synctime-

Since Electron has a battery, you only need to remove the resistor if you are using the Electron without its default battery. That would be if you are say powering the device directly from a beefy 5V supply. That is an unusual use-case but is provided for by removing the 0 ohm resistor.

Actually the sync should happen implicitly on cloud connect, but it needs some time and for that do as @bko said - on the other hand Particle.syncTime() won’t hurt either.

The docs for the mentioned functions should be here
Particle.syncTimeDone()
Particle.syncTimePending()
Particle.syncTimeLast()

And there will also be a dedicated Time.isValid() function in 0.6.1 (which can already be tested in RC stage)

But if you are seeing a wrong time it could also be due to your time zone. If you don’t happen to live in the UTC time zone, you need to set Time.zone(offset) according to your zones time offset.

The time/date is just not set at all (its something like 1979).

I am using the single cell LiPo battery but the device is going into deep sleep. My understanding is that while it’s asleep the battery is not powering the internal RTC as the regulator shuts off during sleep. Is it possible to keep the RTC running independent of it sleep/wake status?

That’s not the case.

1 Like

Ok thanks. So as long as it gets a sync over the cloud the device can go into a deep sleep for however long and it will retain the correct time (as long as the battery is not disconnected)?

Generally speaking, yes.
But the RTC has some drift, so it’s recommended to resync from time to time - e.g. once a day.

1 Like