Modified the begin method so that it performs a real check on the RTC connection

This commit is contained in:
Th3maz1ng 2019-05-01 22:03:24 +02:00
parent 42fb3f52bc
commit 8fb329e717
2 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,6 @@
// Code by JeeLabs http://news.jeelabs.org/code/ // Code by JeeLabs http://news.jeelabs.org/code/
// Released to the public domain! Enjoy! // Released to the public domain! Enjoy!
// Added a real begin verification for the ds3231 01/05/2019 Th3maz1ng
#include <Wire.h> #include <Wire.h>
#include "RTClib.h" #include "RTClib.h"
@ -433,7 +434,8 @@ void RTC_PCF8523::writeSqwPinMode(Pcf8523SqwPinMode mode) {
boolean RTC_DS3231::begin(void) const { boolean RTC_DS3231::begin(void) const {
Wire.begin(); Wire.begin();
return true; Wire.beginTransmission(DS3231_ADDRESS);
return Wire.endTransmission() == 0;
} }
bool RTC_DS3231::lostPower(void) const { bool RTC_DS3231::lostPower(void) const {

View File

@ -1,5 +1,6 @@
// Code by JeeLabs http://news.jeelabs.org/code/ // Code by JeeLabs http://news.jeelabs.org/code/
// Released to the public domain! Enjoy! // Released to the public domain! Enjoy!
// Added a real begin verification for the ds3231 01/05/2019 Th3maz1ng
#ifndef _RTCLIB_H_ #ifndef _RTCLIB_H_
#define _RTCLIB_H_ #define _RTCLIB_H_