Features

The kode dot integrates two real time clocks, the internal one of the ESP32-S3 and one external.

Connection diagram

The internal ESP32-S3 clock can be used directly using the Espressif documentation. The external clock is connected to the I2C of the ESP32-S3 using these connections:
External RTCESP32-S3
SDAGPIO48
SCLGPIO47
INTAEXP2
INTBEXP1
The external clock has the address 0xD0 on the I2C bus.
The interrupt pins are connected to the IO expander.

Arduino

ESP-IDF

  • TBD

Example code

This code configures the RTC with a specific date and time and then prints the current time every second.
rtc_test.ino
/**
 * Demo básico de tiempo con RTC MAX31329: establece una hora inicial y lee/muestra la hora continuamente.
 * Utiliza API fluida (rtc.t.year = 2024) para configurar la hora fácilmente en ESP32-S3.
 * Imprime la hora formateada cada segundo en el monitor serie.
 */
/* ───────── KODE | docs.kode.diy ───────── */

#include <kode_MAX31329.h>
#include "Wire.h"

MAX31329 rtc;

/* Función auxiliar para leer y mostrar la hora actual desde el RTC */
static void printTime()
{
	/* Leer hora del RTC en la estructura rtc.t */
	if (!rtc.readTime()) {
		Serial.println("Error al leer la hora (readTime failed)");
		return;
	}
	
	/* Formatear e imprimir la hora como YYYY-MM-DD HH:MM:SS */
	Serial.printf("%04d-%02d-%02d %02d:%02d:%02d\n", 
		rtc.t.year, rtc.t.month, rtc.t.day, 
		rtc.t.hour, rtc.t.minute, rtc.t.second);
}

void setup()
{
	Serial.begin(115200);
	Serial.println("Ejemplo de hora con MAX31329");
	
    Wire.begin(48,47);

	/* Inicializar el RTC */
	rtc.begin();

	/* Establecer la hora inicial con la API fluida - 24 de noviembre de 2024 15:10:00 */
	rtc.t.year = 2024;
	rtc.t.month = 11;
	rtc.t.day = 24;
	rtc.t.hour = 15;
	rtc.t.minute = 10;
	rtc.t.second = 0;
	rtc.t.dayOfWeek = 0; /* 0=Domingo, 1=Lunes, ..., 6=Sábado */
	
	/* Escribir la hora configurada en el hardware del RTC */
	if (!rtc.writeTime()) {
		Serial.println("Error al escribir la hora (writeTime failed)");
	}
}

void loop()
{
	delay(1000);    /* Esperar 1 segundo entre lecturas */
	printTime();    /* Mostrar hora actual */
}

Descarga de ejemplos

Puedes probar los códigos de ejemplo mediante el IDE de Arduino o el IDE de ESP-IDF o descargar los códigos en nuestro drive: Ejemplos del RTC