Posts: 1
Joined: Tue Feb 20, 2024 6:40 am

Raspberry Pi 5 RTC interaction

Tue Feb 20, 2024 7:08 am

I am using Raspberry Pi 5 to run a .NET program that employs timestamps. Right now i stamp my data with GPS markings (received from RMC sentences that my Waveshare 4G HAT produces through serial port). This gives an estimated accuracy of +- 1 second (GPS timestamps are in 1 second discretes and some time is needed to pipe them through serial port). Since RPi5 has real time clock on board I assumed that it would be convenient to use it. Here I have a few questions:
  1. Docs over the web say that on Linux hardware clock time should be updated automatically when internet connection is present. Therefore it seems I don't need to do it manually in my program. Is it true?
  2. If so, does the

    Code: Select all

    give me the current value from RPi5 RTC?
  3. If it is not true, what is the right way to adjust RTC via, for example, NTP request? In .NET I have a function Iot.Device.Rtc.SystemClock.SetSystemTimeUtc(DateTime dt); which should allow me to set the RTC value. However I can't successfully call this one without root permissions since /dev/rtc0 and /dev/rtc1 are owned by root and I don't seem to find any rtc-related groups (similar to I2C or SPI) that non-sudo user can become a member of. How can I get access to RTC-set function from non-root?
I think I am mostly interested in the first question since if the RTC value is adjusted automatically via NTP request then I don't really have much to worry about. I couldn't find the description of this behavior anywhere in the official doc.

Return to “Other programming languages”