2022-04-04 01:11:04 -04:00
|
|
|
// Funciones de Hora y Fecha usando un RX8025 RTC conectado via I2C y libreria Wire
|
2021-01-05 00:15:16 -03:00
|
|
|
#include <Wire.h>
|
|
|
|
#include "RTClib.h"
|
|
|
|
|
|
|
|
RTC_DS3231 RTC; //Create the DS3231 object
|
|
|
|
|
|
|
|
char weekDay[][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
|
|
|
|
|
|
|
|
//year, month, date, hour, min, sec and week-day(starts from 0 and goes to 6)
|
|
|
|
//writing any non-existent time-data may interfere with normal operation of the RTC.
|
|
|
|
//Take care of week-day also.
|
|
|
|
DateTime dt(2018, 3, 20, 21, 51, 0);
|
|
|
|
|
2022-04-04 01:11:04 -04:00
|
|
|
void setup (){
|
2021-01-05 00:15:16 -03:00
|
|
|
Serial.begin(57600);
|
|
|
|
Wire.begin();
|
|
|
|
RTC.begin();
|
|
|
|
RTC.adjust(dt); //Adjust date-time as defined 'dt' above
|
|
|
|
}
|
|
|
|
|
2022-04-04 01:11:04 -04:00
|
|
|
void loop (){
|
2021-01-05 00:15:16 -03:00
|
|
|
DateTime now = RTC.now(); //get the current date-time
|
|
|
|
Serial.print(now.year(), DEC);
|
|
|
|
Serial.print('/');
|
|
|
|
Serial.print(now.month(), DEC);
|
|
|
|
Serial.print('/');
|
|
|
|
//Serial.print(now.date(), DEC);
|
|
|
|
Serial.print(' ');
|
|
|
|
Serial.print(now.hour(), DEC);
|
|
|
|
Serial.print(':');
|
|
|
|
Serial.print(now.minute(), DEC);
|
|
|
|
Serial.print(':');
|
|
|
|
Serial.print(now.second(), DEC);
|
|
|
|
Serial.println();
|
|
|
|
//Serial.print(weekDay[now.dayOfWeek()]);
|
|
|
|
Serial.println();
|
|
|
|
delay(1000);
|
2022-04-04 01:11:04 -04:00
|
|
|
}
|