Skip to content

No return value when failing to talk to the RTC #13

@YHatahet

Description

@YHatahet

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());
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions