2

I have put RTC (Model is SHIM RTC Realtime Clock Accessory Board) at my RPI.

I need to test if it is working or not.

Is there any command which is checking if it is working or not?

I am using RPI 3B+ and Raspbian Buster.

1
  • 1
    timedatectl should report RTC state
    – Milliways
    Commented Sep 30, 2019 at 22:10

3 Answers 3

3

Googling "SHIM RTC Realtime Clock Accessory Board" we can find a picture and tell that there is a MCP7940N RTC chip onboard, with connects via I2C. So first, related: Using the MCP7940N RTC with the Pi 3B+

To check if it's detected by the Pi, you should be able to use the i2cdetect -y 1 command and see 'UU' for the address 0x6f.

To use it with Rasbian, following these directions you should add

# Enable i2c real-time clock
dtoverlay=i2c-rtc,mcp7940x

to /boot/config.txt. You may also need to run sudo sh -c "echo mcp7940x 0x6f > /sys/class/i2c-adapter/i2c-1/new_device" after a reboot. Then run hwclock --systohc to set the clock. On reboot it should automatically use the date and time from the RTC.

To test if it's working correctly start up the Pi without any internet access (unplugging Ethernet and disabling WiFi). The time should be set correctly.

2
  • 1
    Your procedure is concise, clear, and complete. I have been using the other RTC, DS3231 and I think your instructions is also useful for me. Cheers.
    – tlfong01
    Commented Oct 1, 2019 at 6:19
  • This is correct configuration, now it is working.
    – Jakov
    Commented Oct 3, 2019 at 10:26
4

timedatectl will show the current status of the clock and RTC (if fitted)

      Local time: Tue 2019-10-01 12:16:29 AEST
  Universal time: Tue 2019-10-01 02:16:29 UTC
        RTC time: Tue 2019-10-01 02:16:30
       Time zone: Australia/Sydney (AEST, +1000)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

If the RTC is missing or not correctly installed it will show RTC time: n/a

2
  • Great way to easily check it.
    – Jakov
    Commented Oct 3, 2019 at 10:27
  • I prefer Seamus' answer below, as it tells more about a working RTC
    – user333869
    Commented Nov 28, 2023 at 12:05
3

I prefer to use this command:

$ sudo hwclock -rv 

It's more affirmative and informative wrt the RTC status IMO. For example, here's an output from earlier today:

$ sudo hwclock -rv 
hwclock from util-linux 2.33.1
System Time: 1646036590.206071
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
ioctl(4, RTC_UIE_ON, 0): Invalid argument
Waiting in loop for time from /dev/rtc0 to change
...got clock tick
Time read from Hardware Clock: 2022/02/28 08:23:11
Hw clock time : 2022/02/28 08:23:11 = 1646036591 seconds since 1969
Time since last adjustment is 1646036591 seconds
Calculated Hardware Clock drift is 0.000000 seconds
2022-02-28 02:23:10.689309-06:00

You can also compare the time from your system clock against the time from your RTC:

$ date +"%Y-%m-%d %T.%6N"; sudo hwclock -r
2024-06-10 04:26:27.236823
2024-06-10 04:26:27.296659+00:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.