-
Notifications
You must be signed in to change notification settings - Fork 712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DS3231 to add get_aging, set_aging to adjust the internal xtal capacitor to refine time drift #305
Comments
See issue #299, which I believe this is a duplicate of. See also pull requests #270 and #300. Given that the former PR has been stale for 17 months, it looks to me like the maintainers are not exceptionally eager to add this functionality. Also, this repo has been in low-intensity maintenance for almost two years. |
Thank you edgar-bonet, yes, #300, #299 and #270 are all aiming in the same direction, so of course you wouldn't want another variant. I'll continue to use my cut but will keep an eye on any future updates in this space in RTClib. I see lots of work and tests with terrypin999; well done. |
Your code does not discard out of bounds attempts. If you void RTC_DS3231::set_aging(int8_t aged) { //20240630 PBS added aging
if ((aged < 128)&&(aged >= -128)) { //only allow legal aging value ranges
write_register(DS3231_AGING_OFFSET_ADDR, aged);
}
} As
I recommend you always enable all compiler warnings: this can help you catch many programmer errors like this one. |
@PeteB27: Oh, sorry, I was most likely wrong about the warnings on the IDE. 🙁 I seldom use the IDE myself, as I generally prefer using a good old Makefile. It is likely that this IDE setting affects the building of the sketch only, and is not honored when building the Arduino core and the libraries. |
Ah cool, thanks edgar-bonet, I'll relax (for a while) :-). I haven't used Makefile directly since my VS working days. |
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.
The text was updated successfully, but these errors were encountered: