I have been trying to install a RTC on my raspberry pi 2 (running Raspbian Jessie lite 2015-11-21) and I run into the following problem that puzzles me:

  1. I set the correct time on the hardware clock and shut down the pi.
  2. I unplug the ethernet cable so that the pi is off the internet.
  3. I turn on again after about 7/8 minutes and check date and hwclock -r: and here is what I get:

    • Date gives me the correct time (and so does /var/log/syslog). --> so the RTC has done its job.
    • But hwclock -r gives me the wrong time! So it seems hwclock is overwritten by something at boot, after it has passed the time correctly to the system.

And of course if I reboot a second time, then date becomes wrong.

Screen shot

Anyone has an idea of how to fix this?

Here are the current config files. I started without changing config.txt and hwclock-set, and the result was the same:

sudo nano /boot/config.txt: added at the end:


/lib/udev/hwclock-set: commented out:

#if [ -e /run/systemd/system ] ; then
#    exit 0



and /etc/rc.local

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
sudo hwclock -s

The RTC model: http://thepihut.com/products/mini-rtc-module-for-raspberry-pi?variant=758601217

  • Can you paste the configuration files in your answer, please?
    – Jacobm001
    Feb 9, 2016 at 0:30
  • 1
    The link you quoted is old, and relates to a previous OS. Tell us WHAT YOU HAVE DONE. We can only guess otherwise.
    – Milliways
    Feb 9, 2016 at 1:02
  • I have added the config files, let me know if you need anything else. Feb 9, 2016 at 13:56

2 Answers 2


The only thing you should need to do is to add the following line to /boot/config.txt


Inserting commands into init.d or attempting to load modules is unecessary (and may interfere with normal operation). Device Tree should do all this automatically.

You can use ds1307 if you actually have one (the device you linked uses DS3231)

You can turn off fake-hwclock if you want, but it should not be necessary. If you do want to do this you should use the systemd command

systemctl stop fake-hwclock.service
  • It's funny you mention the driver is not the same, I hadn't noticed. In their tutorial they talk about ds1307 only. thepihut.com/blogs/raspberry-pi-tutorials/… Feb 10, 2016 at 14:13
  • I tried what you said, removing all the RTC config form /etc/ and adding ds3231 after dtoverlay=i2c-rtc and it works fine. Hopefully this is the end of the story.. Feb 10, 2016 at 14:44
  • one question though, in Dmesg, I get the line: [ 4.936860] rtc-ds1307 1-0068: rtc core: registered ds3231 as rtc0 with do I get rtc-ds1307 there? Feb 10, 2016 at 14:45
  • I also get the message rtc-ds1307 1-0068: rtc core: registered ds3231 as rtc0. I don't know what it means. The ds1307 and ds3231 are very similar chips (at least the internal registers which hold time) so I suspect they are sharing a common driver.
    – Milliways
    Feb 11, 2016 at 0:47
  • I left my pi to sleep for about half a day and when I plugged it again, the time got reset to 1 jan 1970. Dmesg: rtc-ds1307 1-0068: SET TIME! rtc-ds1307 1-0068: rtc core: registered ds3231 as rtc0 Do you think it's a pb with the clock this time? Feb 11, 2016 at 13:21
sudo update-rc.d fake-hwclock disable S 6

...And reboot. See man fake-hwclock. This is enabled by default on current versions of Raspbian.

  • it seems it has solved my problem! Feb 9, 2016 at 19:05
  • @Clémentine It made your problem go away. You should set the correct overlay in /boot/config.txt and not modify /etc/rc.local. You are mixing 2 different incompatible methods. My setup (with fake-hwclock) works properly (even if the RTC is missing). The device you linked uses DS3231 so you are not using the correct driver.
    – Milliways
    Feb 9, 2016 at 22:38
  • It turns out it hasn't solved my problem fully in fact.. From time to time (and i'm not sure yet when..) the hwclock is reset at boot to 1 jan 1970. I will investigate further and post an update. Feb 10, 2016 at 14:14
  • Tried this, and found my Raspberry in 1970. May 12, 2017 at 15:41

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.