Skip to content

Commit 74e32c8

Browse files
add callWireBegin for rtclib workaround
1 parent c2913e7 commit 74e32c8

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

DS3231_RealtimeClock/DS3231_RealtimeClock.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ DS3231_RealtimeClock::DS3231_RealtimeClock(int scl_pin, int sda_pin, uint8_t eep
1717
_rtc = new RTC_DS3231();
1818
}
1919

20-
void DS3231_RealtimeClock::begin() {
20+
void DS3231_RealtimeClock::begin(bool callWireBegin) {
2121
// rtc
22-
Wire.begin(_sdaPin, _sclPin);
23-
Wire.beginTransmission(DS3231_ADDRESS);
24-
if (Wire.endTransmission() != 0) {
25-
Log.warning(F("Initializing DS3231... Error!" CR));
22+
if (callWireBegin) {
23+
Wire.begin(_sdaPin, _sclPin);
24+
Wire.beginTransmission(DS3231_ADDRESS);
25+
if (Wire.endTransmission() != 0) {
26+
Log.warning(F("Initializing DS3231... Error!" CR));
27+
}
28+
} else {
29+
_rtc->begin(&Wire);
2630
}
2731

2832
if (_rtc->lostPower()) {

DS3231_RealtimeClock/DS3231_RealtimeClock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DS3231_RealtimeClock
1919
{
2020
public:
2121
DS3231_RealtimeClock(int scl_pin = -1, int sda_pin = -1, uint8_t eeprom_address = 0x57);
22-
void begin();
22+
void begin(bool callWireBegin = true);
2323
DateTime now();
2424
DateTime load(int address = 0);
2525
void save(DateTime timestamp, int address = 0);

SystemClock/SystemClock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ SystemClock::SystemClock(
2222
}
2323

2424
void SystemClock::begin() {
25-
_clock->begin();
25+
_clock->begin(false);
2626

2727
startupTime = _clock->startupTime;
2828
}

0 commit comments

Comments
 (0)