RTC Module (DS3231 / DS1307)

Module

A watch for your microcontroller: a real-time clock chip with battery backup keeps date and time through power cuts, so your logger timestamps and your alarm fires even after a reboot.

What it looks like

RTC Module (DS3231 / DS1307)

A typical module — exact shape, colour and markings vary between manufacturers.

Types & variants

DS3231 (TCXO, ±2 ppm — the good one)DS1307 (needs external crystal, drifts more)PCF8563 / PCF8523 (low power)DS3231SN vs cheaper DS3231M variantsRV-3028 (ultra-low-power premium)

Key specs

Accuracy

ppm

DS3231: ±2 ppm (≈1 min/year) thanks to a temperature-compensated crystal; DS1307: ±20+ ppm and temperature-sensitive (minutes/month).

Interface

I2C at address 0x68 (both DS chips); DS3231 modules often add an AT24C32 EEPROM at 0x57.

Backup battery

CR2032 (or LIR2032 rechargeable) keeps time for years. WARNING: many modules ship with a charging circuit that must be disabled for non-rechargeable CR2032s.

Supply

V

DS3231 runs 2.3–5.5 V (3.3 V and 5 V friendly); DS1307 wants 5 V.

Extras

DS3231: two alarms with interrupt output (INT/SQW) and a ±0.25 °C-resolution temperature register; 32 kHz output.

Markings

Module silk: VCC, GND, SDA, SCL, SQW/INT, 32K. Chip marking DS3231SN (better) vs DS3231M (MEMS, slightly worse). ZS-042 is the ubiquitous blue module.

Standard values

ZS-042 DS3231 module (with EEPROM + battery holder), tiny DS3231 'for Pi' modules that plug onto GPIO, DS1307 'Tiny RTC' legacy modules.

How to choose

1) Just buy DS3231 — the accuracy gap vs DS1307 is enormous for ₹50 extra. 2) With a CR2032 (non-rechargeable), remove the charging resistor/diode on ZS-042 boards, or fit a LIR2032. 3) For coin-cell-powered dataloggers, PCF8523/RV-3028 sip far less backup current. 4) Use the INT pin to wake a sleeping MCU at alarm time — that's the low-power design pattern.

Pinout & package

module boardVCC1GND2SDA3SCL4

DS3231 / DS1307 module — I²C header

Check first: Larger DS3231 boards add 32K (32 kHz output) and SQW (alarm/square wave) pins after SCL. Never fit a non-rechargeable CR2032 to a board wired for a rechargeable LIR2032 without cutting the charging resistor.

I2C: VCC, GND, SDA, SCL (+ pull-ups usually onboard), SQW/INT, 32K. Battery holder on the back. Libraries: RTClib (Arduino), built-in RTC support in ESPHome/MicroPython.

Example circuits

  • Arduino data logger stamping SD-card rows with real timestamps
  • ESP32 that sleeps and is woken by the DS3231 alarm INT for hourly readings
  • Digital clock: RTC + 7-segment/OLED display surviving power cuts
  • Raspberry Pi without internet keeping correct time via the kernel's ds3231 overlay

Common failures

Time resets after each power cycle (dead/missing coin cell or wrong battery type), bulged/leaking LIR cells from the charging-circuit-plus-CR2032 mistake, I2C lockups from missing grounds, and DS1307 drifting visibly within weeks.

How to test

I2C scan should find 0x68 (and 0x57 EEPROM on ZS-042). Set the time, power off for a minute, power on — time must have advanced correctly. Read the DS3231 temperature register as a bonus sanity check. Measure coin cell: <2.5 V means replace.

Substitutes

Any I2C RTC with a library port; NTP over WiFi substitutes when the network is reliable (many projects use RTC as NTP's offline backup). GPS modules also provide precise time where sky view exists.

Where to buy