RPi4 Bullseye Cannot retain rtc-ds3231 hwclock value when internet is OFF

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
treeTrunksPi
 
Posts: 38
Joined: Mon Feb 02, 2015 2:38 am

RPi4 Bullseye Cannot retain rtc-ds3231 hwclock value when internet is OFF

Post by treeTrunksPi »

I followed all instructions from Adafruit website but the system clock is still not set after I turn off the internet.

The clock resets to 2000-01-01 00:00:00 when I turn off internet, shutdown, wait for 5 mins, and reopen rpi. I've been trying to fix this for a week now. Any help will be greatly appreciated.

cat /etc/os-release

Code: Select all

PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
sudo apt-get update
sudo apt-get upgrade

sudo nano /boot/config.txt

Code: Select all

dtparam=i2c_arm=on
dtparam=spi=on
dtoverlay=i2c-rtc,ds3231
sudo i2cdetect -y 1

Code: Select all

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --   
sudo apt-get -y remove fake-hwclock
sudo update-rc.d -f fake-hwclock remove
sudo systemctl disable fake-hwclock

sudo nano /lib/udev/hwclock-set

Code: Select all

#!/bin/sh
# Reset the System Clock to UTC if the hardware clock from which it
# was copied by the kernel was in localtime.

dev=$1

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

#/sbin/hwclock --rtc=$dev --systz
/sbin/hwclock --rtc=$dev --hctosys
(WITH INTERNET)

date

Code: Select all

Saturday, 18 March, 2023 01:48:29 AM PST
sudo hwclock -w

sudo hwclock -r

Code: Select all

2023-03-18 01:48:33.448713+08:00
timedatectl

Code: Select all

               Local time: Sat 2023-03-18 01:50:16 PST
           Universal time: Fri 2023-03-17 17:50:16 UTC
                 RTC time: Fri 2023-03-17 17:50:16
                Time zone: Asia/Manila (PST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
dmesg | grep rtc

Code: Select all

[    9.395322] vc4-drm gpu: bound fe206000.pixelvalve (ops vc4_crtc_ops [vc4])
[    9.398153] vc4-drm gpu: bound fe207000.pixelvalve (ops vc4_crtc_ops [vc4])
[    9.398838] vc4-drm gpu: bound fe20a000.pixelvalve (ops vc4_crtc_ops [vc4])
[    9.400108] vc4-drm gpu: bound fe216000.pixelvalve (ops vc4_crtc_ops [vc4])
[    9.400820] vc4-drm gpu: bound fec12000.pixelvalve (ops vc4_crtc_ops [vc4])
[   10.793556] rtc-ds1307 1-0068: registered as rtc0
[   10.797266] rtc-ds1307 1-0068: setting system clock to 2000-01-01T00:13:09 UTC (946685589)
(WITHOUT INTERNET)

Code: Select all

pi@raspberrypi:~ $ date
Saturday, 01 January, 2000 08:00:49 AM PST
pi@raspberrypi:~ $ sudo hwclock -r
2000-01-01 08:00:56.567891+08:00
pi@raspberrypi:~ $ timedatectl
               Local time: Sat 2000-01-01 08:01:04 PST
           Universal time: Sat 2000-01-01 00:01:04 UTC
                 RTC time: Sat 2000-01-01 00:01:04
                Time zone: Asia/Manila (PST, +0800)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no
pi@raspberrypi:~ $ dmesg | grep rtc
[    8.691900] rtc-ds1307 1-0068: SET TIME!
[    8.717235] rtc-ds1307 1-0068: registered as rtc0
[    8.723796] rtc-ds1307 1-0068: setting system clock to 2000-01-01T00:00:21 UTC (946684821)
[    9.111707] vc4-drm gpu: bound fe206000.pixelvalve (ops vc4_crtc_ops [vc4])
[    9.112320] vc4-drm gpu: bound fe207000.pixelvalve (ops vc4_crtc_ops [vc4])
[    9.112883] vc4-drm gpu: bound fe20a000.pixelvalve (ops vc4_crtc_ops [vc4])
[    9.113234] vc4-drm gpu: bound fe216000.pixelvalve (ops vc4_crtc_ops [vc4])
[    9.113702] vc4-drm gpu: bound fec12000.pixelvalve (ops vc4_crtc_ops [vc4])
pi@raspberrypi:~ $ 
Image

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”