3

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:

dtoverlay=i2c-rtc

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

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

/etc/modules

i2c-bcm2708
i2c-dev
rtc-ds1307

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

Clémentine
  • 353
  • 2
  • 4
  • 15

2 Answers2

3

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

dtoverlay=i2c-rtc,ds3231 

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
Milliways
  • 62,573
  • 32
  • 113
  • 225
1
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.

goldilocks
  • 60,325
  • 17
  • 117
  • 234