jsmith0012
Posts: 1
Joined: Sun Jul 12, 2015 8:53 pm

DS3231 hwclock not working right

Sun Jul 12, 2015 9:06 pm

im trying ti use a DS3231 hwclock on a Pi 2 and i think i got it all working right but its not saving the time properly.

i see the RTC being setup in the dmeg

[email protected] ~ $ dmesg | grep rtc
[ 4.596119] rtc-ds1307 1-0068: SET TIME!
[ 4.656566] rtc-ds1307 1-0068: rtc core: registered ds3231 as rtc0

but

[email protected] ~ $ sudo hwclock -r
hwclock: The Hardware Clock registers contain values that are either invalid (e.g. 50th day of month) or beyond the range we can handle (e.g. Year 2095).

so i checked the data that is stored in the registers of the rtc.

[email protected] ~ $ sudo cat /sys/class/i2c-adapter/i2c-1/1-0068/rtc/rtc0/since_epoch
3029529709

the time is not set on the clock. so i go ahead and set the time to the rtc clock.

[email protected] ~ $ date
Sun Jul 12 21:02:47 UTC 2015
[email protected] ~ $ sudo hwclock -w
[email protected] ~ $ sudo hwclock -r
Sun 12 Jul 2015 21:02:59 UTC -0.497060 seconds
[email protected] ~ $ sudo cat /sys/class/i2c-adapter/i2c-1/1-0068/rtc/rtc0/since_epoch
1436734984

but after reboot the clock is back up to that huge number and im back to getting the same error message.

i have replaced the battery one already ... no idea what to do :(

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: DS3231 hwclock not working right

Wed Jul 22, 2015 4:21 pm

Same here.
It's a PITA, this stuff brakes every once in a while, after upgrading the RPi.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: DS3231 hwclock not working right

Wed Jul 22, 2015 5:07 pm

After a

Code: Select all

sudo rpi-update
and a reboot, it seems that in "/boot/config.txt"
you need

Code: Select all

dtoverlay=i2c-rtc,ds1307
instead of

Code: Select all

dtoverlay=ds1307-rtc
But please double check this.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

drgeoff
Posts: 10527
Joined: Wed Jan 25, 2012 6:39 pm

Re: DS3231 hwclock not working right

Wed Jul 22, 2015 5:19 pm

The moral of this is "Don't run rpi-update unless you really know what you are doing.".

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: DS3231 hwclock not working right

Wed Jul 22, 2015 5:22 pm

I ran rpi-update after the issue, to have a new known working configuration for my DS1307.

I suspect that just an apt-get upgrade broke something.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

Return to “Beginners”