Sparktime example always returns same time

Hi all,

I’ve been trying to get the sparktime library working, but all the example programs returns the same time. It simply does not get the time from server. I’ve got always the same time, even when i insert an invalid UDP client. What can I do about it. Does it have someting to do with my router? I’ve tried all the examples on this forum wich works for many people.

Thanks in advance.

Hi @Jasper298

It sounds like you are never getting synchronized–the SparkTime object has a method that will tell you if you have ever sync’ed correctly:

  if (rtc.hasSynced()==true) {
  } else {
    Serial.print("Not synced");

Where in the world are you located? Is it possible your ISP or your router is blocking NTP connections? Can other hosts on the same network get time services?

The cloud-based time code is also available if you don’t need the precision of NTP:

That is the problem. It’s not geting synchronized. My laptop can reach the and even my router is using the same address for getting the time synchronized. What could be wrong?
I would like to use the NTP if possible. I also would like to try spark.syncTime, but i’m not sure wich labrary i need for that.

Hi @Jasper298

There are two separate ways to get real-time on the Spark core: (1) my NTP-based SparkTime library and (2) the built-in Time library doc’ed here

My library is a pretty standard NTP implementation but does not use the ARM RTC; instead it uses millis() as an offset. The built-in library gets time from the cloud and uses the built-in RTC and uses Spark.syncTime();

If you want to continue using my NTP-based library, one issue might be that “” is not one single host but a DNS address that tries to find a host close to you and returns a different host every time you do a DNS lookup on it. This helps to share the load but it makes debugging more difficult.

Is there anything special or unusual about your DNS setup? A problem some folks have run into is that the DNS host address gets messed up on their core and it can be hard to fix. A seemingly common element to all the failures is that the network connection is slow, so that DNS requests timeout often. The symptom is that a certain DNS host value gets stuck in the TI CC3000 and it does not work right for any DNS lookup. You can run this code below to check:

void setup() {

void loop() {
    IPAddress dnshost(ip_config.aucDNSServer[3], ip_config.aucDNSServer[2], ip_config.aucDNSServer[1], ip_config.aucDNSServer[0]);

// a value of means DNS setup did not work

If you have this problem, you can download a DNSclient library but you will have to modify my library slightly to use it. Let me know what you get and I will help you.

Hi @bko,

I’ve ran the test code from your latest post, and indeed, the IP address has an value of

I wrote a complete time RTC code for a ST Cortex M3, but can’t use it on the spark core.

Now, i’ve used the Spark.syncTime() function, it is working and i do get the time. Which is the most accurate option.

Hi @Jasper298

Spark.syncTime() gets the time from the cloud and is fairly accurate. Direct NTP using my library is slightly more accurate but you probably wouldn’t notice without some careful measurement.

Your core will have trouble with any host name (as opposed to an IP address) since DNS is hosed on your core. @Hootie81 wrote a lovely DNS client library that lets you work around this problem, but the NTP library would need a small change to take advantage of it. Let me know if you want to pursue that.

Can you say if your network is slow or has a complicated DNS setup? We are still gathering data on what makes this problem appear.

Hi bko,

Sorry for my late reply, the NTP is still not working. I’ve tried different routers, but nothing helps.
For me, the Spark.syncTime() is accurate enough. And I’m using that one when i needed some timesync.
I do not have a slow network or (as far as i know) not a complicated DNS. I will ask my internet provider…

For now, it is just playing around with the Spark Core. Normally I’m a FPGA (with VHDL) developer and not very good in C, so I’m practising with the Spark Core and also with the Cortex family of ST.

1 Like

Hi @Jasper298

You can fix the DNS problems on your core (at least temporarily) by re-applying the TI “deep update” patch. That will help you use your core more fully since as it stands right now, the core will not allow you to turn internet names like “” into IP addresses like That is why you are having trouble with NTP since it uses a host name, not an IP address.