Can Spark get the time / date from the cloud server?

I would like to use the core as a clock. I’m not sure if that can be done without an RTC. Either way, is it possible to get time from server? Or from other source? Thank you!

6 Likes

@Sparky The Core does have an RTC, but we haven’t really made any libraries for interacting with it. However it’s there and if you want to dig into the firmware you can definitely fiddle with it.

As for getting time from the server, this is a great idea; I could imagine having a Spark.time() function or something that would return the time from the cloud server. Adding to our feature backlog.

Does the on-board RTC set its time via the server? It’d be great to have a seamless RTC capability which used the on-board RTC for sketches but which didn’t have to worry about setting it, adjusting for DST, etc. I’d like to accurately timestamp sensor data on the Core even when out in the field somewhere and it’d be great if there was an easy API for that via the RTC.

1 Like

Currently no, but this is definitely a feature we should add, and I see no reason we couldn’t implement it this way (seamlessly updating time from our servers)

2 Likes

Zach, I would like to ‘second’ the request for this feature… it would be great to get time via a Spark.time() function which would update the onboard RTC. then time would be kept accurate for awhile locally. then on occasion the core could check time via Spark.time().
Several use cases for it including setting time on power up if the RTC was not backed up.

2 Likes

yes, getting time from a server is definitly a must-have!. But for other regions than US the cloud server time won’t be very helpful. Of course you can adjust by adding timezone difference, but think of the different start and end dates of daylight saving time in different regions of the world. so it would be more helpful to have someting like that for NTP

Spark.time(“server”, [local daily clocktime of sync]).

For my region (Europe/Germany/CET) for the offical clocktime this would look like

Spark.time(“ptbtime1.ptb.de”, “04:00”)

(or perhaps from a local server or router supporting NTP)
Europe DST schedule : We change to DST on last Sun in March at 02:00, and back on last Sun in Oct at 03:00 (which means UTC+2 / UTC+1). So you need to make sure you are sync with that somehow.

2 Likes

Good feedback @mf2105, @Dave from our team suggested the same thing (that people should have access to their own NTP servers).

1 Like

Is this feature still being considered?

I’m making an internet-connected garden controller and I wouldn’t want the sprinklers to go off in the middle of a party, just because my code thinks it’s early in the morning… although that could be fun in its own way :smiley:

This post by Nick Ludlam from Berg http://engineering.bergcloud.com/2014/08/problem-with-ntp/ is quite relevant here. He mentions that some ISPs are now blocking access to NTP.

Could just get current time during startup handshake with spark servers over HTTP instead. Problem solved.

1 Like

The Spark Cloud connection can provide time services:

http://docs.spark.io/firmware/#libraries-time

4 Likes

This is great!
I have to say, I haven’t been around here too much over the last few months, and there is clearly a lot of work going on. The core has really matured as a product.