Voltaje que puede aplicarse al reloj: entre 3,3V y 5,5V.
Lleva una pila de 3V tipo CR2032.
Dimensiones de la placa:
- Alto: 38mm alto + 5mm de los pins
- Ancho: 23mm
- Profundidad: entre 10mm y 15mm según se suelden los pins. Profundidad mínima: 10mm
Vista de la placa...
Real Time Clock (RTC) conectado a un ESP32 y a un display LCD para mostrar fecha y hora
Esquema de conexión...
Programa utilizado en este montaje
// Programa basado en el que se puede descargar desde la página web
// https://linuxhint.com/ds3231-rtc-module-esp32/
// al que se le han añadido comandos para visualizar la Fecha y Hora
// en un display LCD de 16x2 caracteres conectado por I2C
#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
RTC_DS3231 rtc; // Initialize an instance of the RTC_DS3231 class
int lcdColumns = 16;
int lcdRows = 2;
LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);
void setup() {
Serial.begin(115200);
Wire.begin();
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Inicializando...");
if (!rtc.begin()) {
Serial.println("RTC not detected");
while (1); // Hang indefinitely if RTC is not found
}
//Uncomment the below line to set the initial date and time
//rtc.adjust(DateTime(__DATE__, __TIME__));
// rtc.adjust(DateTime(2016,8,31,13,55,00));
// rtc.adjust(DateTime( año, mes, dia, hora, minuto, segundo ));
}
void loop() {
// Read current time from the sensor (DS3231)
DateTime now = rtc.now();
// Print the date and time on the same line with two digits for hours, minutes, and seconds
Serial.print("Current Date: ");
Serial.print(now.year(), DEC);
Serial.print("/");
printTwoDigits(now.month());
Serial.print("/");
printTwoDigits(now.day());
Serial.print(" Current Time: ");
printTwoDigits(now.hour());
Serial.print(":");
printTwoDigits(now.minute());
Serial.print(":");
printTwoDigits(now.second());
Serial.println();
// Clear the LCD
lcd.clear();
// Print the date and time on the LCD
lcd.setCursor(0, 0); // Set the cursor to the top-left corner
lcd.print("Fecha ");
printTwoDigits(now.day());
lcd.print("/");
printTwoDigits(now.month());
lcd.print("/");
lcd.print(now.year(), DEC);
lcd.setCursor(0, 1); // Set the cursor to the second row
lcd.print("Hora ");
printTwoDigits(now.hour());
lcd.print(":");
printTwoDigits(now.minute());
lcd.print(":");
printTwoDigits(now.second());
lcd.print(" ");
delay(1000); // Update every 1 second
}
void printTwoDigits(int number) {
if (number < 10) {
Serial.print("0"); // Add a leading zero for single-digit numbers
lcd.print("0");
}
Serial.print(number);
lcd.print(number);
}
Pulsa aquí para descargar el código "esp32rtc.ino"
Pulsa aquí para descargar la librería RTClib
Vídeo del funcionamiento de este montaje (Formato: .mp4 - Tamaño 39,6 MB)...


