I'm trying to incorporate the UdpNtpClient example into my own project that involves a color LCD Shield (from sparkfun) to print any text to the shield including the time fetched from the internet using the mentioned example.
i can print anything to my LCD Shield using LCDPutStr(char* string, int x, int y, int TxtColor, int BGColor);
The UdpNtpClient example outputs long int. the lcd shield needs char*. how can i use the output of the example as an input for the LCDPutStr function?
something like:
char buffer[12];
sprintf(buffer, "%s", longtime);
lcd.print(buffer);
might help
might help
On the other hand, if you are expecting the output to look like 4:45:00 PM, that won't work.
You'll need to convert the Unix time (that long int) to date/time format first. Not all that difficult, but by no means trivial.
Guys, I am running the Ethernet example app UdpNtpClient on the 0022 version of the IDE.
It does not seem to be reliable, the time changes significantly after different responses. 15:20:21 then 5 seconds later 22:50:40. The serial buffer seems to be over written as well. The Seconds since Jan 1 1900 is varying and I can't imagine it is a fault with the ntp server.
I am running the standard example from the Ethernet package running on an EtherTen.
Also I noted the serial buffer is having issues with characters getting lost.
I suspect something else is interfering or over writing, but not sure where to start.
Perhaps there is a patch I have not come across yet.
Can anyone point me in the right direction here
Thanks
Seconds since Jan 1 1900 = 3226231209
Unix time = 1017242409
The UTC time is 15:20:9
Sesince Jan 1 1900 = 3226231221
Unix time = 1017242421
The UTC time is 15:20:21
Sonds since Jan 1 1900 = 3528226240
Unix time = 1319237440
The UTC time is 22:50:40
Snce Jan 1 1900 = 3528226251
Unix time = 1319237451
The UTC time is 22:50:51
Seconds since Jan 1 1900 = 3528226262
Unix time = 1319237462
The UTC time is 22:51:2
Seconds since Jan 1 1900 = 3528226273
Unix time = 1319237473
The UTC time is 22:51:13
Snce Jan 1 1900 = 3528226284
Unix time = 1319237484
The UTC time is 22:51:24
Sorry, poll rate is 10 seconds, not 5 by default.
Also I noted the serial buffer is having issues with characters getting lost.
That can happen. Serial data transmission is not guaranteed. On the other hand, we have not seen your code, so there may be issues with your code.
PaulS, it is the standard example from the Ethernet examples, UrpNtpClient