If your clock is off by several minutes per hour, this would suggest that the clock is either borked or that the battery in it is flat. If it was only a couple of seconds per day, you would have been able to fine tune it by setting the aging register:
#define DS3231_AGING_OFFSET 0x10
int8_t ds3231_get_aging_offset()
{
//Returns the aging offset, defaults to 0
Wire.beginTransmission(DS3231_ADDRESS);
Wire.write(DS3231_AGING_OFFSET);
Wire.endTransmission();
Wire.requestFrom(DS3231_ADDRESS, 1);
return Wire.read() & 0xFF;
}
void ds3231_set_aging_offset(int8_t offset, bool force_conversion = true)
{
//offset = a value from -127 .. 127
//force_conversation = force the clock to use the value immediately
//Negative values will speed up the module.
//A change of +/- 1 will adjust the time base by 0.12ppm
Wire.beginTransmission(DS3231_ADDRESS);
Wire.write(DS3231_AGING_OFFSET);
Wire.write(offset);
Wire.endTransmission();
if (force_conversion)
{
Wire.beginTransmission(DS3231_ADDRESS);
Wire.write(DS3231_CONTROL);
Wire.endTransmission();
Wire.requestFrom(DS3231_ADDRESS, 1);
uint8_t ctrl = Wire.read() | (1 << 5);
Wire.beginTransmission(DS3231_ADDRESS);
Wire.write(DS3231_CONTROL);
Wire.write(ctrl);
Wire.endTransmission();
}
}
The aging register should be set when the time is also set, usually after a battery replacement.
EDIT: By fine tuning the aging offset of one of my cheap DS3231 modules, it is only off by less than one second over a period of several (5 as far as I recall) months.