-
Notifications
You must be signed in to change notification settings - Fork 6
now()
Arnd edited this page Dec 12, 2020
·
2 revisions
This function returns the current RTC date and time as a "DateTime Class" class. It is the only function that reads the RTC datetime value.
...
DS3231M_Class DS3231M; // Create an instance of the DS3231M
...
void setup() {
Serial.begin(SERIAL_SPEED);
while (!DS3231M.begin()) { // Initialize RTC communications
Serial.println("Unable to find DS3231M. Checking again in 1 second.");
delay(1000);
} // of loop until device is located
DateTime now = DS3231M.now(); // get the date and time from RTC
Serial.print("Year: "); Serial.println(now.year());
Serial.print("Month: "); Serial.println(now.month());
Serial.print("Day: "); Serial.println(now.day());
Serial.print("Hour: "); Serial.println(now.hour());
Serial.print("Minute: "); Serial.println(now.minute());
Serial.print("Second: "); Serial.println(now.second());
...
} // of setup