Specifications
0No specs listed.
Pinout
16| Pin | Name | Functions | Notes |
|---|---|---|---|
| 1 | 32kHz | GPIO | 32kHz output |
| 2 | VCC | POWER | Supply |
| 3 | INT#/SQW | GPIO | Interrupt / square wave |
| 4 | RST# | GPIO | Reset |
| 5 | NC | — | No connection |
| 6 | NC | — | No connection |
| 7 | NC | — | No connection |
| 8 | NC | — | No connection |
| 9 | NC | — | No connection |
| 10 | NC | — | No connection |
| 11 | NC | — | No connection |
| 12 | NC | — | No connection |
| 13 | GND | GND | Ground |
| 14 | VBAT | POWER | Backup battery + |
| 15 | SDA | I2C | I2C data |
| 16 | SCL | 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
4Starter 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
| Pin | Arduino Uno R3 | ESP32 DevKitC (WROOM-32) | Notes |
|---|---|---|---|
| VCC | +5V | 3V3 | 2.3-5.5 V |
| GND | GND | GND | |
| SCL | A5/SCL | GPIO22 | I2C clock (see flag re: source record) |
| SDA | A4/SDA | GPIO21 | I2C data (see flag re: source record) |