diff --git a/RTClib.cpp b/RTClib.cpp index b3c8a70..4160f7e 100644 --- a/RTClib.cpp +++ b/RTClib.cpp @@ -755,13 +755,16 @@ static uint8_t bin2bcd(uint8_t val) { return val + 6 * (val / 10); } /**************************************************************************/ /*! - @brief Startup for the DS1307 - @return Always true + @brief Start I2C for the DS1307 and test succesful connection + @return True if Wire can find DS1307 or false otherwise. */ /**************************************************************************/ boolean RTC_DS1307::begin(void) { Wire.begin(); - return true; + Wire.beginTransmission(DS1307_ADDRESS); + if (Wire.endTransmission() == 0) + return true; + return false; } /**************************************************************************/ @@ -995,13 +998,16 @@ DateTime RTC_Micros::now() { /**************************************************************************/ /*! - @brief Start using the PCF8523 - @return True + @brief Start I2C for the PCF8523 and test succesful connection + @return True if Wire can find PCF8523 or false otherwise. */ /**************************************************************************/ boolean RTC_PCF8523::begin(void) { Wire.begin(); - return true; + Wire.beginTransmission(PCF8523_ADDRESS); + if (Wire.endTransmission() == 0) + return true; + return false; } /**************************************************************************/ diff --git a/examples/pcf8523/pcf8523.ino b/examples/pcf8523/pcf8523.ino index b008105..45e75c8 100644 --- a/examples/pcf8523/pcf8523.ino +++ b/examples/pcf8523/pcf8523.ino @@ -14,6 +14,7 @@ void setup () { if (! rtc.begin()) { Serial.println("Couldn't find RTC"); + Serial.flush(); // ensure above text prints with nRF52 native USB Serial while (1); } diff --git a/examples/pcf8523Countdown/pcf8523Countdown.ino b/examples/pcf8523Countdown/pcf8523Countdown.ino index b670521..0ca5e36 100644 --- a/examples/pcf8523Countdown/pcf8523Countdown.ino +++ b/examples/pcf8523Countdown/pcf8523Countdown.ino @@ -41,6 +41,7 @@ void setup () { if (! rtc.begin()) { Serial.println("Couldn't find RTC"); + Serial.flush(); // ensure above text prints with nRF52 native USB Serial while (1); }