Current state of hardware RTC support



What’s the current state of balenaOS regarding hardware RTCs?
I’m trying to use a DS1307 based RTC on my RaspberryPi.

I found an old thread here: Disabling access to RTC
There it is mentioned that chronyd is managing the system time.
But in the general documentation, it is mentioned that one can enable the RTC with the given dtoverlay configuration:

Since the RaspberryPi always connects to balenaCloud (and I assume it syncs the time with the server), it is quite difficult to know if the time is taken from the RTC or from NTP.

At least hwclock on the host OS is giving me this error (which lets me assume it is not enabled):

root@<id>:~# hwclock -r
hwclock: can't open '/dev/misc/rtc': No such file or directory



Hi, have you enabled the DC1307’s interface (normally it’s on I2C as much as I can tell). See some example in the docs

I think you would need to set for your device RESIN_HOST_CONFIG_dtoverlay (or BALENA_HOST_CONFIG_dtoverlay supported on newer OS versions) to "i2c-rtc,ds1307", which enables the i2c-rtc interface and that specific RTC driver…

Could you give this a try, and let us know how it goes?


Thanks for the quick response.

Setting BALENA_HOST_CONFIG_dtoverlay to "i2c-rtc,ds1307" resulted in the RTC working:

root@<id>:~# hwclock -r
Tue Apr 30 06:00:25 2019  0.000000 seconds

Now to the first part of my question above: does this mean, chronyd will use the RTC when the device doesn’t have connection to the balenaCloud? Is there a way for me to verify this?


You can run timedatectl and check that the RTC time property is correctly set


Hi, the whole process is decsribed quite well in this documentation:



Thanks @thundron and @nmaas87 for your explanation.

Unfortunately the linked documentation does not mention an external (I2C) RTC at all. My assumption is, that it will work because systemd-timesyncd manages everything and will also use the external RTC.

But I guess, I will have to test the entire setup on a separate disconnected network using a development build and SSH to 22222.


For everybody reading this thread and wondering the same thing I did:

:+1: Yes, the hardware DS1307 based RTC works fine after adding the following setting:
BALENA_HOST_CONFIG_dtoverlay = "i2c-rtc,ds1307"

The RTC will recover the system time (as expected) even if it was disconnected from the Raspberry Pi; of course as long as it has a battery.

Thanks to everybody who helped me implement and verify this!


How would this work with other overlays already defined? Just getting started with my project but according to what I read I had to set RESIN_HOST_CONFIG_dtoverlay = pi3-miniuart-bt so that the serial port would work (currently reading from a sensor). I tried adding a second entry for the 'i2c-rtc,ds3231" but as expected it gave an error message saying the environment variable was already defined. Is there a way to combine the two entries in one overlay or what is the proper way of doing this?


the use of the RESIN_HOST_CONFIG_dtoverlay parameter is documented here: . If you have further question feel free to contact us again.


Thanks, that worked!