Setting DS3231 RTC accurately

I have a project that I plan to use the Arduino only a few minutes each day. I am planning on waking it up with a DS3231 board. I have looked at several tutorials to set the RTC's time. Each one has the time hard coded into a program. This cannot be that accurate. How to I access time from my computer or the internet and use that. In my case it does not really matter that much. I want it to run sometime late evening or early morning. The exact time does not matter but I would like it to be consistent and as long as I am setting the time, I might as well get it right. Any advice would be appreciated. If there are other ways to wake the arduino up every 24 hours, I would consider those also.

Anthony

How to I access time from my computer or the internet and use that.

Does your Arduino project have Internet access (Ethernet, WiFi)? If so you can use an NTP server to get the time and set the DS3231. Google "setting DS3231 with ntp server" for more information.

Check your library. There may be a function that will let you get and use the PC system time (at compile time) to set the RTC. See here.

Thank you for the reply. I thought maybe it could access the internet through my PC. The project will have an A6 GSM board. I can receive texts with that board but I don't know if I can access the internet. It also supports GPSR but that sounds like accessing a server and I am not sure what to do with that.

Google "arduino access ntp server" for lots of hits on how to set up to get the time from the Internet. I set up an NTP client in my weather station to get the time from the Internet. It was not too difficult and I was pretty new to the networking part back then.

Great - thanks - I didn't even know what an NTP server was and I was having a touch time wrapping my head around not having a browser.

Thanks for the help.

Anthony

The 3231 is fine but, if you are so serious about time accuracy and are still in the planning stage, you might consider a Node-MCU or ESP 32, both of which are dirt cheap and have WiFi built-in, thereby enabling you to use NTP - no PC needed.

most if not all examples offer a way to set the time.

you put in the numbers for something a minute into the future.
upload the sketch

turn you PC clock so show seconds hands

at the instant of the times you press reset.

the sketch runs and sets the time.

now, you edit your sketch and remark out the part tht sets the time.
and you upload that.

now, until you remove the battery or go into change the clock, the RTC will be on your time.