Page 1 of 1

RTC not storing time & date (solved)

Posted: Tue May 20, 2014 4:21 pm
by Bashster
Hi all,

My Pi is no longer retaining its date and time settings between reboots; just reverts back to jan 1st 2000 every time now.
I have never had any problems with this clock (4d rtc board) before in over a year it's been totally reliable. The battery is fine at just over 3V so I'm lost. How should i proceed to track down this fault? ISTR there are some commands to detect the clock function is working but can't recall what they are.

cheers.

Re: RTC not storing time & date

Posted: Tue May 20, 2014 4:37 pm
by DougieLawson
If the clock is off by more than 1000s seconds then ntp can't reset it. NTP also relies on having a good internet connection to some servers in the debian.pool.ntp.org

Try
ping -c3 0.debian.pool.ntp.org
sudo ntpd -gq

If that doesn't work try updating /etc/ntp.conf to use pool.ntp.org (rather than the debian subdomain).

ntpq -p
and
ntptime
will tell you if ntpd is running OK.

hwclock is the command to work with RTC hardware.

Re: RTC not storing time & date

Posted: Tue May 20, 2014 5:37 pm
by Bashster
I don't use internet servers. I want my Pi isolated from the net altogether; that's why I installed the add-on clock board.

Re: RTC not storing time & date

Posted: Tue May 20, 2014 5:39 pm
by DougieLawson
What's the RTC based on? Is it a DS1307 chip?
How do you set the clock first time and write that to the RTC?

https://learn.adafruit.com/adding-a-rea ... t-rtc-time has the recipe.

Re: RTC not storing time & date

Posted: Tue May 20, 2014 6:30 pm
by Bashster
It's a Maxim DS1338 chip.
I created a root password and then did the date -s "20 MAY 2014 13:00:00" command. Only works for the session, though and reverts to the year 2000 on reboot.

Re: RTC not storing time & date

Posted: Tue May 20, 2014 6:41 pm
by DougieLawson
Did you write the time to the RTC with sudo hwclock -w and read it back with hwclock -r?

http://www.hobbytronics.co.uk/raspberry-pi-rtc-module has another recipe (which convinced me that your DS1338 is just a 3V3 version of the DS1307 that I'm running).

Re: RTC not storing time & date

Posted: Tue May 20, 2014 6:57 pm
by Bashster
No, I just used the 'date -s' method. Should work ok, shouldn't it?

Re: RTC not storing time & date

Posted: Tue May 20, 2014 7:01 pm
by DougieLawson
Bashster wrote:No, I just used the 'date -s' method. Should work ok, shouldn't it?
That only sets the Linux system clock. It doesn't write the time to the RTC module. You MUST use sudo hwclock -w to do that or you'll get the exact symptoms you're seeing.

Re: RTC not storing time & date

Posted: Tue May 20, 2014 7:18 pm
by Bashster
OK, well I shall try your suggested approach and report back. I just don't recall doing it any other way than with the date command before, but my memory is not what is was..... we shall see..

Re: RTC not storing time & date

Posted: Tue May 20, 2014 7:56 pm
by Bashster
Doug, I am going to have to defer this attempt to tomorrow. I'm getting huge levels of grief from SWMBO as I've been paying too much attention to the computer and not enough to her, apparently. many thanks for your assistance thus far. i hope this fixes it but will report back tomorrow either way.

cheers,

B.

Re: RTC not storing time & date

Posted: Wed May 21, 2014 12:46 pm
by Bashster
Phew! Thanks, Doug. It works now! :D