Time Synchronisation Accuracy

Hi Everyone,
The time of my cores seem to be slow by a few (4) seconds?
Where do they get the time from?


The core synchronises with the Spark :cloud: upon handshake when it powers on to sync :clock6:.

You can us Spark.syncTime()` to re-synchronize time but it shouldn’t really be too off from the initial synced time.

See: http://docs.spark.io/firmware/#spark-synctime


1 Like

Hi Kenneth,
Yes I tried this but same result, about 4 seconds slow… Also just after startup is same…
Where does the time sync to? is that source correct?

That’s probably the server time i think!

Can you watch the stream: https://api.spark.io/v1/events?access_token=xxxxxxxxx

You should see the time posted by each stream and have a quick comparison to the time you are referencing to? :smiley:

Interesting, the stream seems to be in time with http://time.is
but the core seems behind?

1 Like

Any ideas?, Trying to build a clock, but time is not true?

Hi @andyg

You can try calling Spark.syncTime() more often (maybe once an hour). There is logic in the real-time clock code to slowly move between the current time and the new time when the clock is set to avoid a big jump in time that might be effecting you, but four seconds is a lot.

If you want more accurate time, you can try my NTP-based SparkTime library (available in the web IDE libraries section). It was created before the Spark built-in time class existed but it does have a few extra features like daylight savings time handling for the US and Europe. In my experience it is accurate to withing one second.

1 Like

I am interested in tight time synchronization for a timing application I work on from time to time (where sensors on multiple devices take part in an overall event timing system); for this to work with the best accuracy possible the various devices need to maintain tight time synchronization (I am looking at 1-ms level accuracy if possible).

I’ve been looking at protocols for this (this is a nice summary : http://www.cs.wustl.edu/~jain/cse574-06/ftp/time_sync/index.html ) and one of the requirements for high accuracy is being able to have the low-level communications code drop a timestamp into a packet at the latest possible time in the stack, so that time of flight delays (including software stack and protocol times) can be estimated.

I haven’t yet poked around a lot in the Spark libraries but am wondering if anyone has tinkered with the communications at this level.

You might be interested in my NTP based real-time library available here and in the web IDE.


Thanks - I’ll have to tinker with that when I get back into hacking on this stuff.

@andyg, did you ever get this resolved? I’m finding the time is out by four seconds, too.