DS3231 real-time clock (RTC) module
DS3231 real-time clock module (ZS-042): pins, 0x68 + 0x57 EEPROM addresses, RTClib, and why a CR2032 can be overcharged on this board.
Community draft — report a mistake
3.3 V or 5 V? The module pulls SDA/SCL up to its own VCC. On a 3.3 V board, power it from 3.3 V — the DS3231 keeps excellent time at 3.3 V.
The DS3231 is a temperature-compensated real-time clock: it keeps the date and time while your board is off, running from a coin cell. It is far more accurate than the older DS1307, which makes it the right choice for timers, data loggers and irrigation schedules.
The coin-cell trap. The common blue ZS-042 board has a resistor and diode that try to charge the backup cell. That is fine for a rechargeable LIR2032 but bad for an ordinary CR2032, which must never be charged. With a CR2032, remove the charging resistor (or the diode) — or fit an LIR2032 instead.
The same board carries an AT24C32 EEPROM at 0x57 you can use for a few kilobytes of settings. The SQW pin can wake a sleeping microcontroller on an alarm.
Pinout
| Pin | What it does |
|---|---|
32K | 32.768 kHz square-wave output (optional) |
SQW | Alarm interrupt / programmable square wave (open-drain) |
SCL | I2C clock |
SDA | I2C data |
VCC | Supply, 2.3–5.5 V |
GND | Ground |
I2C address:0x680x57
Library
RTClib by Adafruit
Arduino IDE → Library Manager → search the name above. Each guide lists the exact version we compile against.
Use it with
- DS3231 real-time clock (RTC) module with Arduino Mega 2560 Arduino C++
- DS3231 real-time clock (RTC) module with Arduino Nano Arduino C++
- DS3231 real-time clock (RTC) module with Arduino Uno R3 Arduino C++
- DS3231 real-time clock (RTC) module with ESP32-C3 SuperMini Arduino C++
- DS3231 real-time clock (RTC) module with ESP32 DevKit V1 Arduino C++
- DS3231 real-time clock (RTC) module with NodeMCU ESP8266 Arduino C++
- DS3231 real-time clock (RTC) module with Raspberry Pi Pico W MicroPython
Common errors
Time resets to 2000-01-01 after power loss
The backup cell is flat or missing. Fit a fresh coin cell (and see the charging note below before you use a CR2032).
Two I2C addresses show up
Normal: 0x68 is the DS3231 and 0x57 is the AT24C32 EEPROM on the same board.
Clashes with an MPU6050
Both answer at 0x68. Pull the MPU6050’s AD0 pin high to move it to 0x69.
Time drifts by minutes a month
You probably have a DS1307 or a fake DS3231. A genuine DS3231 is temperature-compensated and drifts about a minute a year.