DS3231 RTC Precision Real Time Clock
DS3231 RTC Precision Real Time Clock is backordered and will ship as soon as it is back in stock.
The DS3231 Precision Real Time Clock module is a high accuracy RTC solution for Arduino, ESP32, ESP8266, Raspberry Pi, and other microcontroller projects that require reliable timekeeping. It uses a temperature compensated crystal oscillator to maintain accurate time even when the main system is powered off, making it ideal for data logging, clocks, automation systems, and IoT applications.
Unlike basic RTC modules, the DS3231 provides excellent long term accuracy with minimal drift. A built in backup battery holder allows the module to keep time during power loss, while the I2C interface ensures simple integration with most development boards and libraries.
Key Features
- High accuracy temperature compensated RTC
- Very low drift compared to DS1307 based modules
- Integrated crystal oscillator
- Battery backup support for time retention
- I2C interface for easy wiring
- Widely supported by Arduino and Raspberry Pi libraries
Technical Specifications
- RTC chip DS3231
- Accuracy typically ±2ppm from 0°C to 40°C
- Supply voltage 3.3V to 5V
- Communication protocol I2C
- Default I2C address 0x68
- Backup battery CR2032 coin cell - NOT included
- Dimensions: 22x38x14mm
Quick Example Arduino DS3231 RTC
This quick example shows how to read the current date, time, and internal temperature from the DS3231 RTC using the popular RTClib library. It prints a formatted timestamp and temperature to the Serial Monitor, making it ideal for testing wiring and confirming correct operation.
New to Arduino? First go through our Arduino Getting Started Guide for Beginners, where we go over installing the Arduino IDE and how to upload code to your board.
DS3231 Arduino Wiring
| DS3231 Pin | Arduino Uno Pin | Description |
|---|---|---|
| VCC | 5V or 3.3V | Power supply |
| GND | GND | Ground |
| SDA | A4 | I2C data line |
| SCL | A5 | I2C clock line |

Example Code
This sketch automatically sets the RTC time when power is lost and then continuously reads the current date, time, and temperature every three seconds.
/* * Ethan Zaitchik * DS3231 RTC Precision Real Time Clock Basic Example * Product page: https://zaitronics.com.au/products/ds3231-rtc-precision-real-time-clock */ #include "RTClib.h" RTC_DS3231 rtc; char daysOfTheWeek[7][12] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; void setup () { Serial.begin(9600); if (!rtc.begin()) { Serial.println("RTC not detected"); while (1); } if (rtc.lostPower()) { Serial.println("RTC lost power, setting time"); rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); } } void loop () { DateTime now = rtc.now(); String yearStr = String(now.year()); String monthStr = (now.month() < 10 ? "0" : "") + String(now.month()); String dayStr = (now.day() < 10 ? "0" : "") + String(now.day()); String hourStr = (now.hour() < 10 ? "0" : "") + String(now.hour()); String minuteStr = (now.minute() < 10 ? "0" : "") + String(now.minute()); String secondStr = (now.second() < 10 ? "0" : "") + String(now.second()); String dayOfWeek = daysOfTheWeek[now.dayOfTheWeek()]; String formattedTime = dayOfWeek + ", " + yearStr + "-" + monthStr + "-" + dayStr + " " + hourStr + ":" + minuteStr + ":" + secondStr; Serial.println(formattedTime); Serial.print("Temperature "); Serial.print(rtc.getTemperature()); Serial.println(" C"); Serial.println(); delay(3000); }
For Arduino Uno and Nano, SDA connects to A4 and SCL connects to A5. On ESP32 and ESP8266 boards, SDA and SCL can usually be assigned to multiple pins depending on your code. Raspberry Pi boards use dedicated I2C pins on the GPIO header.
Board Compatibility
- Arduino Uno, Nano, Mega, Leonardo
- ESP32 and ESP8266 development boards
- Raspberry Pi including Pi 3, Pi 4, and Pi Zero
- Other microcontrollers with I2C support
Common Applications
- Data logging with accurate timestamps
- Digital clocks and time displays
- Home automation and scheduling
- IoT devices requiring persistent time
- Embedded systems and low power projects
Alternative Real Time Clock Modules
- Adafruit DS3231 Precision RTC Breakout
- Adafruit DS3231 Precision RTC STEMMA QT
- Adafruit PCF8523 Real Time Clock Assembled Breakout Board
- Adafruit DS1307 Real Time Clock Assembled Breakout Board
- Adafruit PiRTC PCF8523 Real Time Clock for Raspberry Pi
The DS3231 RTC module is an excellent choice when accuracy, reliability, and ease of use matter. It is a popular upgrade over older RTC modules and a solid option for both beginners and advanced electronics projects.
This product can be found here:




