adafruit / RTClib

A fork of Jeelab's fantastic RTC Arduino library
MIT License
797 stars 707 forks source link

RTC_DS3231::begin always returns true, so it cannot be used to detect absence of DS3231 device #96

Closed SapientHetero closed 5 years ago

SapientHetero commented 6 years ago

However, this version does, and it seems likely it would work just fine for the DS1307 too. Feel free to add it to the library if you find it useful.

boolean RTC_DS3231::begin(void) {
  Wire.begin();
  Wire.beginTransmission (DS3231_ADDRESS);                      // added 7/24/2018 at 1:13pm
  if (Wire.endTransmission () == 0)                             //
    return true;                                                
  else                                                      //
return false;                                               //
}
mouridis commented 5 years ago

Thanks @SapientHetero. I had this issue and your solution works fine. Tested on ESP32 with DS3231.

This is soooo useful, I don't know why it's not added to the library already.

drak7 commented 5 years ago

Duplicate of #64 , please submit a PR if you'd like to merge this.