I’ve been reading in the photon documentation about setTime() instruction:
Set the system time to the given timestamp.NOTE: This will override the time set by the Particle Cloud. If the cloud connection drops, the reconnection handshake will set the time again
However this doe not appear to be the case. I’ve put it in setup and as soon as it connects to the cloud, the time stamp resets to the current time of a given zone.
My project requires the photon to start with the same time, every time power is applied.
The very moment when
Particle.syncTime() kicks in is not that precisely defined.
In AUTOMATIC mode, you get a cloud connection, then your code starts running and a short while after this, the sync time will happen.
So in order to prevent this to happen, you should either use SEMI_AUTOMATIC and do all your tasks before calling
Particle.connect() or you wait till the sync has definetly happend (e.g. by checking
Time.year()) and reset the time then.
But may I ask, what kind of code does require an arbitrary given time and just waste the RTC capabilities of the device?
Maybe rethinking this requirement would be good