====== IrtcRead() ====== ''IrtcRead()'' reads the RTC date and time. {{:en-us_commands:reference:irtcread.svg?900|IrtcRead command operation flow}} ''bool IrtcRead(IrtcDateTime& dateTime)'' ===== Commands ===== ^ Command ^ Arguments ^ Return Value ^ Operation ^ | ''IrtcRead(dateTime)'' | ''IrtcDateTime& dateTime'' | ''bool'' | Reads the RTC date and time. | ===== 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|IrtcBegin() View detailed description]] * [[:en-us_commands:reference:irtcset|IrtcSet() View detailed description]] * [[:en-us_commands:reference:irtcunixtime|IrtcUnixTime() View detailed description]] * [[:en-us_commands:reference:irtcgettemperature|IrtcGetTemperature() View detailed description]] * [[:en-us_commands:reference:irtctimevalid|IrtcTimeValid() View detailed description]] * [[:en-us_commands:reference:irtcclearoscillatorstopflag|IrtcClearOscillatorStopFlag() View detailed description]] * [[:en-us_commands:reference:irtcsetalarm1|IrtcSetAlarm1() View detailed description]] * [[:en-us_commands:reference:irtcsetalarm2|IrtcSetAlarm2() View detailed description]] * [[:en-us_commands:reference:irtcalarmenable|IrtcAlarmEnable() View detailed description]] * [[:en-us_commands:reference:irtcalarmenabled|IrtcAlarmEnabled() View detailed description]] * [[:en-us_commands:reference:irtcalarmtriggered|IrtcAlarmTriggered() View detailed description]] * [[:en-us_commands:reference:irtcsquarewave|IrtcSquareWave() View detailed description]] * [[:en-us_commands:reference:irtc32khz|Irtc32kHz() View detailed description]] [[:en-us_commands:builtin|← Built-in Command List]]