Setting a custom device time, without having to change SYSTEM_MODE


Build on Photon, using Device OS 1.0.1, via IDE

I’ve been working on a custom clock, for a while, and its been a hard slog for a while, mostly to do with issues around keeping the device synced over a few days. However my issue at the moment is testing Daylight savings calculations, and I need to test how it handles my code.

I’m at the stage of testing and therefore want to intentionally set it to given time stamps, so I can check how it handle powering on and off at different times of the year and passing though the change of daylight savings…

So I am having trouble getting it to take a specific time.

I’ve written an extremley simple snippet of code to set the device to 03/30/2019 @ 11:55pm (UTC), which is 5min before midnight close to the up and comeing daylight saving event here in the new year:


void setup() {


void loop() {

Serial.println("Date:- " + Time.timeStr());


So it prints out the set time I want for about 5 seconds and then jumps to the real world time now.

The only way I can see to over come this is to change my SYSTEM_MODE, which is with the above code default automatic… I think… And that means rigging up an interupt button to be able switch it back to automatic to be able to OTA update my code everytime I tweek it…

So my question is… Is there an easyier way to do this? IE stop the Device OS running off and updating the device time, after I’ve preset it, without loosing other functions.



The automatic sync happens when the device first connects to the cloud (plus a few seconds).
But once done it won’t happen again till you lose connection and reconnect again (or call Particle.syncTime()).
So you should just need to wait a few seconds till the connection was established and the auto-sync has happened and set your own time after that.
For testing you may even want to use a Particle.function() to set any arbitrary time on-the-fly.

BTW, you can’t change the SYSTEM_MODE at runtime but you don’t need to either. Once your program runs you can use Particle.disconnect() and Particle.connect() to control the cloud connection at your will.
Also no need for an interrupt, you can also poll the state of any pin and act upon that.


Ah, right…

So I think a 10 second pause, is the way to go. Once I’ve got my code set and tested it will be enough…

I just didn’t want to have to wait 6 months between tests… Coz I ain’t that good a coder.

And I’d really like to put this project to bed… (hanging from the celling actually…) I might even do a hackster documentation…

Once again huge thanks Scruff. Theres a reason your Elite…