Bashster
Posts: 41
Joined: Sat Jan 19, 2013 3:00 pm

RTC not storing time & date (solved)

Tue May 20, 2014 4:21 pm

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.

User avatar
DougieLawson
Posts: 35340
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: RTC not storing time & date

Tue May 20, 2014 4:37 pm

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.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Bashster
Posts: 41
Joined: Sat Jan 19, 2013 3:00 pm

Re: RTC not storing time & date

Tue May 20, 2014 5:37 pm

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.

User avatar
DougieLawson
Posts: 35340
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: RTC not storing time & date

Tue May 20, 2014 5:39 pm

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.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Bashster
Posts: 41
Joined: Sat Jan 19, 2013 3:00 pm

Re: RTC not storing time & date

Tue May 20, 2014 6:30 pm

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.

User avatar
DougieLawson
Posts: 35340
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: RTC not storing time & date

Tue May 20, 2014 6:41 pm

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).
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Bashster
Posts: 41
Joined: Sat Jan 19, 2013 3:00 pm

Re: RTC not storing time & date

Tue May 20, 2014 6:57 pm

No, I just used the 'date -s' method. Should work ok, shouldn't it?

User avatar
DougieLawson
Posts: 35340
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: RTC not storing time & date

Tue May 20, 2014 7:01 pm

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.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Bashster
Posts: 41
Joined: Sat Jan 19, 2013 3:00 pm

Re: RTC not storing time & date

Tue May 20, 2014 7:18 pm

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..

Bashster
Posts: 41
Joined: Sat Jan 19, 2013 3:00 pm

Re: RTC not storing time & date

Tue May 20, 2014 7:56 pm

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.

Bashster
Posts: 41
Joined: Sat Jan 19, 2013 3:00 pm

Re: RTC not storing time & date

Wed May 21, 2014 12:46 pm

Phew! Thanks, Doug. It works now! :D

Return to “Troubleshooting”