-->
Page 1 of 3

Is it possible to run a real time clock in software

PostPosted: Mon May 04, 2015 9:13 am
by nigelbe
I'm looking to make a second perfect digital clock.

I've got one going using DayTime protocol (port 13) from my network which I can poll every second or so. Also I have a NTP client running in another sketch.

I'd really like to use NTP for the clock but it requires you to keep time in software between calls to the NTP server.

Any ideas welcome,

Nigel.

Re: Is it possible to run a real time clock in software

PostPosted: Mon May 04, 2015 10:07 am
by gerardwr
I use the Time library from the Arduino Playground to keep the time.
http://playground.arduino.cc/code/time

You can update the local time/date from the library using the DAYTIME or NTP data on a regular basis (every hour or so).

Re: Is it possible to run a real time clock in software

PostPosted: Mon May 04, 2015 10:46 am
by jra
+1 the Time library. The version from https://www.pjrc.com/teensy/td_libs_Time.html works with the NTPClient.ino example distributed with https://github.com/esp8266/Arduino. Once you obtain a precise value for the time, set the local clock via setTime(epoch) and then check it after an hour, 24 hours, etc. to see how much your local clock drifts. That will give you an indication how often you need to resync.

Re: Is it possible to run a real time clock in software

PostPosted: Tue May 05, 2015 8:12 am
by nigelbe
Thanks a lot, that works. :D

Next to DST