

The DS3231 RTC module, manufactured by DORHEA (Part ID: DS3231 AT24C32), is a highly accurate real-time clock (RTC) designed to keep track of time and date. It features a temperature-compensated crystal oscillator (TCXO) to ensure precise timekeeping, even under varying environmental conditions. The module communicates via the I2C interface, making it easy to integrate with microcontrollers like Arduino, Raspberry Pi, and other embedded systems.








The DS3231 RTC module is designed for high accuracy and ease of use. Below are its key technical details:
The DS3231 RTC module has the following pinout:
| Pin | Name | Description |
|---|---|---|
| 1 | GND | Ground connection |
| 2 | VCC | Power supply input (3.3V to 5.5V) |
| 3 | SDA | I2C data line (connect to microcontroller's SDA pin) |
| 4 | SCL | I2C clock line (connect to microcontroller's SCL pin) |
| 5 | SQW/OUT | Square wave output or interrupt output (optional, configurable via software) |
| 6 | 32K | 32kHz output (optional, used for external clocking applications) |
The DS3231 RTC module is straightforward to use in a circuit. Below are the steps and best practices for integrating it into your project.
VCC pin to a 3.3V or 5V power source and the GND pin to ground.SDA pin to the SDA pin of your microcontroller.SCL pin to the SCL pin of your microcontroller.SQW/OUT pin for square wave output or alarms if needed.32K pin can be used for an external 32kHz clock signal.Below is an example of how to use the DS3231 RTC module with an Arduino UNO. This code sets the time and reads the current time and date.
#include <Wire.h>
#include <RTClib.h> // Include the Adafruit RTC library
RTC_DS3231 rtc; // Create an RTC object
void setup() {
Serial.begin(9600); // Initialize serial communication
Wire.begin(); // Initialize I2C communication
if (!rtc.begin()) {
Serial.println("Couldn't find RTC module!");
while (1); // Halt execution if RTC is not found
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, setting the time!");
// Set the RTC to the current date and time
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
void loop() {
DateTime now = rtc.now(); // Get the current time and date
// Print the current time and date to the Serial Monitor
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(1000); // Wait for 1 second before updating
}
RTC Not Detected by Microcontroller:
0x68).Incorrect Time or Date:
rtc.adjust() function.Square Wave Output Not Working:
SQW/OUT pin is configured correctly in the software.EEPROM Not Accessible:
0x57) is used when accessing the AT24C32 memory.Q: Can the DS3231 RTC module work without a backup battery?
A: Yes, but it will lose timekeeping functionality when the main power is disconnected.
Q: What is the default I2C address of the DS3231?
A: The default I2C address is 0x68.
Q: How accurate is the DS3231 RTC module?
A: The module has an accuracy of ±2 ppm from 0°C to +40°C, which translates to a drift of about ±1 minute per year.
Q: Can I use the DS3231 with a 3.3V microcontroller?
A: Yes, the module supports both 3.3V and 5V logic levels.
By following this documentation, you can effectively integrate and use the DS3231 RTC module in your projects.