Skip to content
Michael Miller edited this page Sep 25, 2016 · 1 revision

When should I set the time on the RTC module versus trust the time it provides?

It all depends on your use scenario and access to accurate time.

A simple approach is to use the sketch build date time to compare to what is returned from the RTC module. If the sketch time is newer than the Rtc current time; then update the Rtc time; otherwise trust the time the Rtc module has.

A safe approach is to have a specific sketch that will set the time on the module. This sketch may use the sketch build time or a specific technique you come up with.

The best approach is to have a special routine within your sketch that allows you to set the date and time that is triggered from external feature. This could the connection of the serial monitor to allow the user to "send" the current date and time and update the Rtc module.

If your hardware supports internet connections; you could also have your sketch periodically check a internet time server and if the time is more than a few seconds off then update the RTC module. See NIST. Depending on your module, you may only need to do this once a month or less.

You can’t perform that action at this time.