How should the photon sync the time with the cloud

Right now, I want to the spark photon to execute a task at some certain time, but first of all the spark photon needs to sync with cloud to know what is the current time in this timezone, how would I do it ?

Photon synchronizes its internal RTC on the startup, when connecting to cloud. It takes a while, so you may want to wait for it. There is nice thread discussing how to do it. But you have to set the timezone by yourself, if I am not mistaken.

Also having a backup battery on VBAT pin lets Photon keep its RTC running when powered off. If you search for VBAT there are lenghty discussions about it, but somewhat confusing. Not having it would just have you wait for sync each time you power up your Photon. (note though, Core has no VBAT pin, if you by any chance have Spark Core too)

@helxsz, @lami, there is also the Time.syncTime() command to force a cloud time sync. This is useful for updating the time every 24 hours for example. :smile:


Since there is a significant delay in setting up the initial time sync, is there a way to verify that a time sync has completed?
I have a working display that is wrong for the first minute or so, and displays nonsense, after which it jumps to the correct time.
I would like to only display the time after it has been properly setup.

Hi @Awake

I think what a lot of folks are doing is wait for the year to greater than 1970.


Yes there is, look into the thread I linked for code example. But it does exactly what @bko says.

1 Like


I have a silly query.
Why does RTC need to be synced with Cloud? Is it considered to unify the time value of all devices to a common reference?

Good day!

Yes, since the RTC might be running slow/fast or has lost power, so you would want it to sync with a common reference (UTC is the global reference time and hence used by Particle too).
It’s not only the basis for all Particle devices but also for your wrist watch and your mobile phone and computer and …

1 Like

Thank you @ScruffR for the response.