How to Make a Script/Task to Set RTC Regularly? #892
-
I have a NEO-M8T GNSS Timing HAT together with a PiJuice. I use the GNSS HAT to set the system time with PPS (Pulse Per Second). This results in the Pi having accurate time to within ~1 microsecond when idling. My question as in the title is how I can set up a task/script to regularly (every 24 hours say) read the very accurate system time and write it to the RTC of the PiJuice? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
I am assuming you set the Linux system time from the GNSS HAT. |
Beta Was this translation helpful? Give feedback.
-
Yes, the RTC overlay is in the EEPROM. To dump the contents of the eeprom, see https://github.com/raspberrypi/hats/tree/master/eepromutils. |
Beta Was this translation helpful? Give feedback.
I am assuming you set the Linux system time from the GNSS HAT.
Linux internal system time is in UTC.
Just run e.g. a 24h cron job which copies the system time to the RTC:
sudo hwclock --systohc
You might have to also use the --rtc option if your GNSS HAT also has a /dev/rtcx
Of course the device driver for the PiJuice RTC has to be loaded.
See
man hwclock
for more details.Do not expect microsecond precision from the PiJuice RTC.