← All parts

DS3231

DS3231

RTC

DS3231 temperature-compensated I2C RTC (SO-16), high accuracy.

In stock

Specifications

0

No specs listed.

Pinout

16
PinNameFunctionsNotes
132kHz
GPIO
32kHz output
2VCC
POWER
Supply
3INT#/SQW
GPIO
Interrupt / square wave
4RST#
GPIO
Reset
5NC
—
No connection
6NC
—
No connection
7NC
—
No connection
8NC
—
No connection
9NC
—
No connection
10NC
—
No connection
11NC
—
No connection
12NC
—
No connection
13GND
GND
Ground
14VBAT
POWER
Backup battery +
15SDA
I2C
I2C data
16SCL
I2C
I2C clock

Interactive pinout

Highlight:
DS3231

Click a pin to copy its name · tap a tag above to spotlight a bus.

Logic level & voltage

The DS3231 is an I2C real-time clock that works with both 3.3 V and 5 V microcontrollers on typical breakout modules; confirm your specific module's regulator and pull-ups.

Typical uses

  • Accurate timekeeping with temperature-compensated drift
  • Alarms and scheduled wake-ups
  • Dataloggers needing timestamps across power loss

Wiring notes & gotchas

  • Fit a coin-cell backup so time survives main-power loss.
  • I2C needs SDA/SCL pull-ups (usually on the module).
  • Some modules include an EEPROM at a second I2C address — watch for conflicts.

Commonly used with

4

Starter code

Community starter examples — minimal, unofficial, and provided to get you wiring fast. Verify against the manufacturer datasheet before relying on them.

Arduino (C++)

Arduino library: RTClib (by Adafruit)

arduino
// DS3231 real-time clock (I2C) — community starter example
#include <Wire.h>
#include <RTClib.h>

RTC_DS3231 rtc;

void setup() {
  Serial.begin(115200);
  Wire.begin();
  if (!rtc.begin()) { Serial.println("DS3231 not found"); while (1) delay(10); }
  if (rtc.lostPower()) rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));  // set once from build time
}

void loop() {
  DateTime now = rtc.now();
  Serial.print(now.year());  Serial.print('-'); Serial.print(now.month()); Serial.print('-');
  Serial.print(now.day());   Serial.print(' ');
  Serial.print(now.hour());  Serial.print(':'); Serial.print(now.minute()); Serial.print(':');
  Serial.println(now.second());
  delay(1000);
}

MicroPython

python
# DS3231 RTC (ESP32) — community starter example
# raw I2C register read (BCD); a driver like ds3231.py is optional
from machine import Pin, I2C
import time

i2c = I2C(0, scl=Pin(22), sda=Pin(21))
ADDR = 0x68

def bcd2dec(b): return (b >> 4) * 10 + (b & 0x0F)

while True:
    d = i2c.readfrom_mem(ADDR, 0x00, 7)   # sec,min,hour,dow,day,month,year
    print("%02d:%02d:%02d" % (bcd2dec(d[2] & 0x3F), bcd2dec(d[1]), bcd2dec(d[0] & 0x7F)))
    time.sleep(1)

Wiring

PinArduino Uno R3ESP32 DevKitC (WROOM-32)Notes
VCC+5V3V32.3-5.5 V
GNDGNDGND
SCLA5/SCLGPIO22I2C clock (see flag re: source record)
SDAA4/SDAGPIO21I2C data (see flag re: source record)

Related parts

3