Skip to content

Aging Register adjustment: suggested addition #299

Description

@terrypin999

Hobbyist here, not a programmer/developer/techie, so hope you’ll excuse this submission as an ‘Issue’.

I believe that, like me, other RTClib users get clock inaccuracy with the DS3231. Arduino Forum contributor @gfvalvo helped me to implement its adjustment after a simple addition to RTClib.h. So directly below the section

//
/*!
@brief RTC based on the DS3231 chip connected via I2C and the Wire library
*/
/
/
(which in the current release 2.1.3 ends with empty line 400), I’ve inserted the following five lines:

// Add Aging Register Access
static constexpr uint8_t agingRegister = 0x10;
int8_t readAging(){
return read_register(agingRegister);
}
void setAging(int8_t newAgingValue) {
write_register(agingRegister, newAgingValue);
}
};
My own sketch already includes the RTClib library and its minimal initialisation

// Initialize the rtc object
rtc.begin();
to which I added the following five lines in setup(), to compensate for my clock’s current slowness.

// Using edited RTClib.h from gfvalvo to adjust AgingRegister
int8_t aging = rtc.readAging();
Serial.println(aging);
int8_t newAging = -50;
rtc.setAging(newAging);
Trial and error will be needed (before hopefully reducing drift to a couple of seconds a week at most), but I already believe it to be working satisfactorily. The method seems significantly simpler than some I’ve seen, so I’d suggest its serious consideration for a future release please.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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