/************************************************************************/
/************************************************************************/
/***** PONTIFICIA UNIVERSIDAD CATÓLICA DEL PERÚ *****/
/***** FACULTAD DE CIENCIAS E INGENIERÍA *****/
/***** SISTEMAS DIGITALES B *****/
/************************************************************************/
/***** Tema: Comunicación I2C *****/
/***** Proyecto: I2C_RTC *****/
/************************************************************************/
/***** EvalBoard: ESP32 S3 DevKitC 1 *****/
/************************************************************************/
/***** Enunciado: *****/
/***** Programa que muestra el funcionamiento de un reloj de tiempo *****/
/***** real conectado al SoC ESP32-S3 por medio de I2C. *****/
/************************************************************************/
/************************************************************************/
// Incluimos la biblioteca RTClib|
#include <RTClib.h>
// Declaramos el objeto miRTC
RTC_DS1307 miRTC;
void setup() {
// Inicializamos comunicación serial
Serial.begin(115200);
// Inicializamos el RTC
miRTC.begin();
// Ajustamos la hora y fecha a 09:30:00 del 6 de octubre del 2024
miRTC.adjust(DateTime(2024, 10, 6, 9, 30, 0));
}
void loop() {
// Leemos la fecha y hora
DateTime now = miRTC.now();
// Imprimimos la hora actual
Serial.printf("Hora actual: %02d:%02d:%02d\n", now.hour(), now.minute(), now.second());
// Retardo de 1s
delay(1000);
}