Go Down

Topic: Who needs a Software Real Time Clock? (Read 12 times) previous topic - next topic

Digger450

I had some free time today so I finally got around to allowing my Arduino to sync the DateTime over the internet using the wiznet module.  It grabs the time from the NIST server which gives a response like this:

Code: [Select]
54964 09-05-13 21:01:33 50 0 0  14.3 UTC(NIST) *

From that it was a little bit of work figuring how to convert to unix time, but I got it sorted.  The nice thing about using NIST is that it also indicates if it is daylight savings or standard time so the time will always be correct.  No adjustment needed or watching for specific dates.  I currently update the time every twelve hours.  With the price of the wiznet module around $16 I think this trumps having a RTC because of the other things you can do with ethernet.

Currently, this is in a pretty large program on my Sanguino.  If there's interest I could put together an example sketch that simply updates the time from NIST.

Coding Badly

Quote
Are the two compatible, or is there some way to make them compatible?


The majority of the sleep modes on the AT90USB162 processor seem to shut off all the timers (except the watchdog timer).  This means millis stops running.

Hopefully this will help...
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1240918097

Good luck,
Brian

Todd Houstein

Thanks Brian,
I've worked out a new control algorithm that doesn't require date/time, so now I just need to put the arduino to sleep and wake it every few minutes to conserve energy. Looks like the thread you've linked to will do the trick.

Cheers,
Todd

emacsen

I've been looking at this code and there are two general questions I have about it, one technical and one non-technical.

The technical issue is that unless I'm missing something there doesn't seem to be any support for time zones, even implicitly.

The most simple solution to this would be to simply add an offset field in the structure which would be used when calculating the more calendar friendly time structure.

A more complete but complex solution would be to add a simplified time zone function per zone. This wouldn't have the historical time zone information (ie it wouldn't work for past times) but would be "good enough" and relatively small.

Thoughts on either?

The non-technical question is that the code itself has a copyright with all rights reserved, and then no subsequent license that I could find. Is that an oversight or by design?

Thanks

mem

Hi emacsen,

The lack of license statement is oversight. It is licensed under the GNU LGPL and I will add that into the source files when I upload the next version.

In my own code  I handle time zone offset when needed by adding the offset value to calls to DateTime.sync.  But usually I don't need it because the clock on the computer that sets the time is already compensated for the local time zone.

If you think it would be useful to have a timezone property that contained the offset in hours from UTC then I can easily add that.

If you are thinking about displaying multiple time zones, I wonder if it would help if I added something like the following  method:

boolean SetTimeZone(int offsetFromUTC)
// set the time zone offset to the given value
// if time has been synced, refresh time properties and return true
// else return false


This would result in calls to DateTime.hour, DateTime.Day etc reflecting the given time zone offset.

Go Up