Skip to content

DS3231 to add get_aging, set_aging to adjust the internal xtal capacitor to refine time drift #305

@PeteB27

Description

@PeteB27

Is there any interest in adding the read/write of DS3231 aging register (register 0x10) to the RTClib codeset ?

I have prepared a working (and tested) form using release RTClib v2.1.4 that I'm happy to share.
Changes made are contained in the following files:
RTC_DS3231.cpp
RTClib.h

Target system is Arduino MEGA, so the AVR systems like MEGA and NANO etc.

  • Arduino board: Arduino MEGA

  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.19

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):
    Not really relevant as the RTClib codeset does not currently have handlers for reading or adjusting the RTC DS3231 aging register, but as a code snippet, please look at the following sample project file lines:
    int8_t prevDrift=rtc.get_aging(); //to read the aging register value
    rtc.set_aging(newDrift); //to set a new value to the drift register, eg -17, and thus refine the RTC clock drift (speed up the clock by using -ve numbers in ppm, or slow down using +ve numbers).
    Code changes came from DS3231 library, written by Petre Rodan in 2018 and modified to suit your library.

The reason why I changed to your code; you have a working UNIX seconds counter, so for me, that's a big tick.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions