Skip to content

Commit

Permalink
Merge pull request #166 from colindgrant/issue-64-begin-always-return…
Browse files Browse the repository at this point in the history
…s-true

Verify RTC communication in PCF8523 and DS1307 begin()
  • Loading branch information
drak7 authored May 13, 2020
2 parents 3d9e25f + 3f379ab commit 6bff711
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
18 changes: 12 additions & 6 deletions RTClib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**************************************************************************/
Expand Down Expand Up @@ -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;
}

/**************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions examples/pcf8523/pcf8523.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions examples/pcf8523Countdown/pcf8523Countdown.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 6bff711

Please sign in to comment.