Erriez / ErriezDS3231

DS3213 high precision RTC (Real Time Clock) library for Arduino
https://github.com/Erriez/ErriezArduinoLibrariesAndSketches
MIT License
22 stars 7 forks source link

How to ensure that correct time is uploaded to DS3231 #3

Closed mcsysmcsys closed 2 years ago

mcsysmcsys commented 2 years ago

When loading the sketch SetBuildTime, time is updated, but with an offset of about 11 seconds. So the time is not accurate, but 11 seconds later.

How to deal with this?

Erriez commented 2 years ago

Hi @mcsysmcsys, Thanks for using my library.

The sketch ErriezDS3231SetBuildDateTime uses the date/time macro's __DATE__ and __TIME__ at build time. There is a delay between building the sketch and running the sketch which updates the new RTC time. In your case 11 seconds.

If you want to program a more accurate time, you can look at sketch ErriezDS3231Terminal which includes a Python script to sync the time from the computer.

Does this answer your question?

mcsysmcsys commented 2 years ago

Thank you for your answer. Sorry, but I am an NOOB in this field. Appreciate your help.

How would the terminal library help with setting an accurate time?
btw I am a bit puzzled, what is the point of having a fairly accurate clock like ds3231, but with impossibility to set it accurately...

What would be great is a sketch that sets the time using pc time(which is accurate NTP), but also checks if there is an offset. Then setting again compensating for that. Hope that makes sense ;)

Erriez commented 2 years ago

The design depends on the accuracy requirements:

Erriez commented 2 years ago

Closing issue as syncing accurate RTC time is beyond the scope of this library.