-
Notifications
You must be signed in to change notification settings - Fork 5
Real Time Clock
A Real-Time Clock (RTC) module keeps accurate time, even without internet access.
Most common RTC modules with I²C will work. Good starting points include the DS3231 (e.g. this) and the DS1307 (e.g. this).
┌─────┐
│ VCC ├─ +5 V DC
│ GND ├─ 0 V DC
| |
│ SCL ├─ I²C SCL
│ SDA ├─ I²C SDA
└─────┘
┌─────┐
│ VCC ├─ +3.3 V DC
│ GND ├─ 0 V DC
| |
│ SCL ├─ I²C SCL
│ SDA ├─ I²C SDA
| |
│ INT ├─ RTC INT
└─────┘
┌─────┐
│ VCC ├─ +3.3 V DC
│ GND ├─ 0 V DC
| |
│ SCL ├─ I²C SCL
│ SDA ├─ I²C SDA
| |
│ INT ├─ RTC INT
└─────┘
┌─────┐
│ VCC ├─ +3.3 V DC
│ GND ├─ 0 V DC
| |
│ SCL ├─ I²C SCL
│ SDA ├─ I²C SDA
| |
│ INT ├─ RTC INT
└─────┘
┌────────────────┐
│ VIN ├─ +5 V DC
│ 3V3 ├─ +3.3 V DC
│ GND ├─ 0 V DC
│ │
│ SCL ├─ I²C SCL
│ SDA ├─ I²C SDA
│ │
│ Digital input ├─ RTC INT
└────────────────┘
0 V DC ────────┬──────── 0 V DC
+3.3 V DC ────┐ │ ┌──── +5 V DC
┌──┴───┴───┴──┐
│ VCC GND VCC │
I²C SCL ─┤ ──► ├─ I²C SCL
I²C SDA ─┤ ◄─► ├─ I²C SDA
RTC INT ─┤ ◄── ├─ RTC INT
└─────────────┘
Most RTC modules are 3.3 V compatible, but some variants use higher logic levels (e.g. 5 V). In those cases, a logic level shifter is required to ensure safe communication with the ESP32. Make sure it is suited for I²C signals, like TXS0104E (e.g. this).
Serial clock for I²C communication.
Any I²C SCL pin can be used.
Configure in secrets.h:
#define PIN_SCL 1 // I²C SCLBidirectional data line for I²C.
Any I²C SDA pin can be used.
Configure in secrets.h:
#define PIN_SDA 2 // I²C SDAInterrupt signal from the RTC module.
Optional to connect.
Any digital input pin that are also RTC-capable can be used.
Configure in secrets.h:
#define PIN_INT 3 // RTC INTUsing the RTC extension, the clock will automatically sync during during startup.
Check out the RTC extension for more info.
Configure in secrets.h:
#define RTC_DS1307
#define PIN_SCL 1 // I²C SCL
#define PIN_SDA 2 // I²C SDAImportant
Logic level shifter required.
Warning
Incompatible with IKEA Frekvens due to the lack of a 5 V power supply.
Configure in secrets.h:
#define RTC_DS3231
#define PIN_SCL 1 // I²C SCL
#define PIN_SDA 2 // I²C SDA
#define PIN_INT 3 // RTC INTConfigure in secrets.h:
#define RTC_DS3232
#define PIN_SCL 1 // I²C SCL
#define PIN_SDA 2 // I²C SDA
#define PIN_INT 3 // RTC INTConfigure in secrets.h:
#define RTC_PCF8563
#define PIN_SCL 1 // I²C SCL
#define PIN_SDA 2 // I²C SDA
#define PIN_INT 3 // RTC INTExternal links for deeper exploration — provided for reference only and with no formal connection to this project.