Teensy 4.1 - RTC and NTP Time

I want to connect to an NTP server on boot up, read time and use it to set the time on the T4.1 RTC. I will do this once an hour maybe, depending on the drift I get.

I then want to call the RTC typically every few seconds for data logging time stamps.

I have currently have code running which always calls NTP, but I'd prefer a local call to RTC for speed and if there's an internet outage, I'm stuck.

So if I
Code:
setSyncProvider(getTeensy3Time)
will that mean that
Code:
now()
will get time from the RTC? That's what I want.

And how do I set the T4.1RTC to NTP time? I would expect to
Code:
 setTime(t);
but how do I obtain 't', because now() will try and get time from the T4.1RTC

Any help appreciated as always, thanks
 
Back
Top