Real Time Clock - VIPnytt/Frekvens GitHub Wiki
ā° 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).
ā Supported types
š Schematics
DS1307 schema
āāāāāāā
ā VCC āā +5 V DC
ā GND āā 0 V DC
| |
ā SCL āā I²C SCL
ā SDA āā I²C SDA
āāāāāāā
DS3231 schema
āāāāāāā
ā VCC āā +3.3 V DC
ā GND āā 0 V DC
| |
ā SCL āā I²C SCL
ā SDA āā I²C SDA
| |
ā INT āā RTC INT
āāāāāāā
DS3232 schema
āāāāāāā
ā VCC āā +3.3 V DC
ā GND āā 0 V DC
| |
ā SCL āā I²C SCL
ā SDA āā I²C SDA
| |
ā INT āā RTC INT
āāāāāāā
PCF8563 schema
āāāāāāā
ā VCC āā +3.3 V DC
ā GND āā 0 V DC
| |
ā SCL āā I²C SCL
ā SDA āā I²C SDA
| |
ā INT āā RTC INT
āāāāāāā
ESP32 schema
āāāāāāāāāāāāāāāāā
ā 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
āāāāāāāāāāāāāāāāā
Logic level shifter schema
0 V DC āāāāāāāāā¬āāāāāāāā 0 V DC
+3.3 V DC āāāāā ā āāāāā +5 V DC
āāāā“āāāā“āāāā“āāā
ā VCC GND VCC ā
I²C SCL ā⤠A1 āāāŗ B1 āā I²C SCL
I²C SDA ā⤠A2 āāāŗ B2 āā I²C SDA
RTC INT ā⤠A3 āāā B3 āā RTC INT
āāāāāāāāāāāāāāā
āļø Logic level shifter
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).
š§ Configuration
I²C SCL
Serial clock for I²C communication.
Any I²C SCL pin can be used.
Configure in secrets.h:
#define PIN_SCL 1 // I²C SCL
I²C SDA
Bidirectional data line for I²C.
Any I²C SDA pin can be used.
Configure in secrets.h:
#define PIN_SDA 2 // I²C SDA
RTC INT
Interrupt 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 INT
š§© Extension
Using the RTC extension, the clock will automatically sync during during startup.
Check out the RTC extension for more info.
š Templates
DS1307
Configure in secrets.h:
#define RTC_DS1307
#define PIN_SCL 1 // I²C SCL
#define PIN_SDA 2 // I²C SDA
[!IMPORTANT] Logic level shifter required.
[!WARNING] Incompatible with IKEA Frekvens due to the lack of a 5 V power supply.
DS3231
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 INT
DS3232
Configure 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 INT
PCF8563
Configure 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 INT
š Resources
External links for deeper exploration ā provided for reference only and with no formal connection to this project.