The Raspberry Pi doesn't come with a realtime clock; if you want to run a standalone (no network) pi with the proper time automatically set on boot you need a real time clock (rtc).

There are a several rtc chips available, most run on the i2c serial bus and many are made by Dallas Semiconductor (ds1307, ds1339, ds3231).

I've wired up a ds3231 to the pi's i2c bus #1, and I can set the time on it and set the system time from the clock using the hwclock command.

How do I configure raspbian to do this on boot? I have removed the fake-hwclock package, but this only results in the system time being set to January 1969 on boot, which tells me hwclock -s was never run.

In a crude attempt to make this work, I placed the hwclock -s command in /etc/rc.local, but I'd like to use a more proper method.

I see there's an /etc/init.d/hwclock.sh script which is supposed to sync the system time from the rtc, but it bails if udev is configured. This implies udev should handle the sync from rtc->system clock, but it is not configured to do so.

What's the proper way to have the system time set from an rtc at boot on a raspberry pi running raspbian?


1 Answer 1


Add the following line to /boot/config.txt and re-boot.


See /boot/overlays/README for details.

If that doesn't work you will need to reverse any misconfiguration you did previously.

  • dtoverlay=i2c-rtc,ds3231 has already been added to /boot/config.txt, and hwclock works as expected.
    – Jason
    Jan 20, 2017 at 18:23
  • @Jason That is all you need to do. You need to undo anything else you did.
    – joan
    Jan 20, 2017 at 18:28
  • dtoverlay=i2c-rtc,ds3231 should work (it is what I use), not sure about the "=1" which is not mentioned in documentation.
    – Milliways
    Jan 20, 2017 at 23:02
  • OK, that worked fine. @Milliways @Joan the =1 is not required. Thank you guys.
    – Jason
    Jan 20, 2017 at 23:33
  • @joan if you'll edit your response to omit the =1, then I'll accept it as a solution.
    – Jason
    Jan 20, 2017 at 23:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.