-
Notifications
You must be signed in to change notification settings - Fork 83
Open
Labels
Description
If the arduino boots up and the RTC is not connected, it will not return error values for some parameters such as date and time.
A simple fix is to add the following lines of code in every method:
if (!Wire.available())
{
return 99; // Some obvious error value
}
For example in the getSecond() method:
byte DS3231::getSecond() {
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(0x00);
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS, 1);
if (!Wire.available())
{
return 99; // Some obvious error value
}
return bcdToDec(Wire.read());
}