User Tools

Site Tools


en-us_commands:reference:irtcbegin

IrtcBegin()

IrtcBegin() checks the DS3231 RTC connection and starts using it.

IrtcBegin command operation flow

bool IrtcBegin()

Commands

Command Arguments Return Value Operation
IrtcBegin() None bool Checks the DS3231 RTC connection and starts using it.

Example

void setup() {
  Serial.begin(115200);
 
  if (!IrtcBegin()) {  // Check the DS3231 RTC connection and begin operation.
    Serial.println(F("DS3231 connection failed"));
    return;
  }
 
  // Run once initially, then comment out.
  // IrtcSet(2026, 8, 10, 14, 30, 0);
}
 
void loop() {
  IrtcDateTime now;
  if (IrtcRead(now)) {  // Read the RTC date and time.
    Serial.print(now.year);
    Serial.print('/');
    Serial.print(now.month);
    Serial.print('/');
    Serial.print(now.day);
    Serial.print(' ');
    Serial.print(now.hour);
    Serial.print(':');
    Serial.print(now.minute);
    Serial.print(':');
    Serial.println(now.second);
  }
  delay(1000);
}

Precautions

Run each device's corresponding Begin command first. Check I²C addresses and pin sharing; if the bool return value is false, inspect wiring and power.

Built-in Commands in the Same Category

en-us_commands/reference/irtcbegin.txt · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki