uugear/Witty-Pi-4

Serious RTC time drift - is there a test/calibrate function?

jbuck2005 opened this issue · 1 comments

Is there a calibration or test routine that can be run? It appears that my RTC is losing 5s per day!!!! This is really not acceptable and I would like to look into what options exist to remedy this.

piuser@pinamehere:~ $ uptime
14:08:31 up 1 day, 4:58, 2 users, load average: 0.18, 0.17, 0.17

piuser@pinamehere:~ $ ntpq -pn

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.debian.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.002
 1.debian.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.002
 2.debian.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.002
 3.debian.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.002
 10.0.2.255      .BCST.          16 B    -   64    0    0.000    0.000   0.002
+162.159.200.1   10.29.9.214      3 u   25   64    1   64.747    0.918  11.347
-199.182.221.110 101.202.201.204  2 u   22   64    1  123.619    1.086  11.976
+209.115.181.110 10.0.0.80        2 u   23   64    1    6.367   -0.824   0.915
-192.99.168.180  210.65.119.71    2 u   20   64    1   83.245   -0.074  12.291
*66.70.172.17    206.108.0.133    2 u   23   64    1   84.781   -0.493  11.801

piuser@pinamehere:~ $ ./wittypi/wittyPi.sh

================================================================================
|                                                                              |
|   Witty Pi - Realtime Clock + Power Management for Raspberry Pi              |
|                                                                              |
|            < Version 4.13 >     by Dun Cat B.V. (UUGear)                     |
|                                                                              |
================================================================================
>>> Current temperature: 32.375°C / 90.275°F
>>> Your system time is: 2023-07-31 14:08:36 EDT
>>> Your RTC time is:    2023-07-31 14:08:31 EDT
>>> Vout=5.28V, Iout=0.02A
Now you can:
  1. Write system time to RTC
  2. Write RTC time to system
  3. Synchronize with network time
  4. Schedule next shutdown
  5. Schedule next startup
  6. Choose schedule script
  7. Set low voltage threshold  [3.1V]
  8. Set recovery voltage threshold  [3.5V]
  9. Set over temperature action
 10. Set below temperature action
 11. View/change other settings...
 12. Reset data...
 13. Exit
What do you want to do? (1~13) 
uugear commented

The I2C register No.37 is to store the offset value for RTC calibration. Usually this value has been properly set in the factory, but it can be lost if firmware was updated without keeping the EEPROM values. It is possible to calibrate the RTC again by measuring the CLKOUT frequency in (unpopulated) P5 header, or count the actual time drift.

Here is an excel file that can calculate the offset value for I2C register No.37:
WittyPi_RTC_Calibration.xlsx

This Excel file provides two approaches (by frequency or by time drift) to calculate the offset value. Properly setting the I2C register No.37 will make the RTC accuarate.