1. Introduction
The DORHEA DS3231 Real Time Clock (RTC) module is a low-cost, highly accurate I2C RTC with an integrated temperature-compensated crystal oscillator (TCXO) and crystal. It provides precise timekeeping for various microcontroller projects, including Raspberry Pi and Arduino. The module maintains accurate time and date information, including seconds, minutes, hours, day, date, month, and year, with automatic leap year compensation up to the year 2100. It operates across a wide voltage range of 3.3V to 5.5V.
Figure 1: Top view of the DS3231 RTC module, showing the coin cell battery holder.
2. Features
- Complete clock calendar functions: seconds, minutes, hours, day, date, month, and year.
- Valid up to the year 2100 with automatic leap year compensation.
- Integrated temperature-compensated crystal oscillator (TCXO) for high accuracy.
- Digital temperature sensor with ±3°C accuracy.
- Timing accuracy maintained at ±5ppm (±0.432 seconds/day) over -40°C to +85°C.
- Low power consumption.
- 1Hz and 32.768kHz output.
- I2C serial bus interface (400kHz high-speed).
- Operating voltage: +2.3V to +5.5V.
3. Setup and Connection
The DS3231 module connects to your microcontroller (e.g., Raspberry Pi, Arduino) via the I2C bus. Ensure your microcontroller's I2C interface is enabled and configured correctly.
3.1 Pinout Diagram
Figure 2: Pinout of the DS3231 RTC module.
- GND: Ground connection.
- NC (empty): No connection.
- SCL: I2C Serial Clock line. Connect to your microcontroller's SCL pin.
- SDA: I2C Serial Data line. Connect to your microcontroller's SDA pin.
- VCC: Power supply input (+2.3V to +5.5V). Connect to your microcontroller's 3.3V or 5V supply.
3.2 Initial Connection Steps
- Identify the I2C pins (SDA, SCL, GND, VCC) on your microcontroller.
- Connect the DS3231 module's GND pin to your microcontroller's Ground.
- Connect the DS3231 module's VCC pin to your microcontroller's 3.3V or 5V power supply.
- Connect the DS3231 module's SDA pin to your microcontroller's SDA pin.
- Connect the DS3231 module's SCL pin to your microcontroller's SCL pin.
- Ensure the coin cell battery is correctly inserted into the battery holder for backup power.
Important Note on Battery Charging: Some versions of this module may include a charging circuit for the coin cell battery. If you are using a non-rechargeable CR2032 battery, it is recommended to disable the charging circuit to prevent damage to the battery and potential hazards. This typically involves desoldering a specific resistor (often labeled "102" or similar) near the glass diode on the module. Consult online resources or the module's specific schematic for detailed instructions on disabling the charging circuit if necessary.
4. Operating Instructions
After connecting the module, you will need to use a software library compatible with your microcontroller to communicate with the DS3231 via the I2C bus. The I2C address for the DS3231 RTC module is typically 0x68. Some modules also include an AT24C32 EEPROM, which has a separate I2C address (typically 0x57).
4.1 Basic Operations (Conceptual)
- Setting Time and Date: Use the appropriate library functions to write the current time (seconds, minutes, hours) and date (day, date, month, year) to the DS3231 registers.
- Reading Time and Date: Use library functions to read the current time and date from the DS3231 registers. The module automatically updates these values.
- Reading Temperature: The DS3231 includes an integrated digital temperature sensor. Library functions can be used to read the ambient temperature.
- 1Hz Output: The module provides a 1Hz square wave output on a dedicated pin (if available on your specific module variant), which can be used for synchronization.
Refer to the documentation of your chosen microcontroller platform (e.g., Arduino IDE, Raspberry Pi OS) and the specific DS3231 library for detailed code examples and API usage.
5. Maintenance
5.1 Battery Replacement
The DS3231 module uses a CR2032 coin cell battery to maintain timekeeping when the main power supply is disconnected. The battery life can extend for several years. When the timekeeping becomes unreliable after power loss, the battery may need replacement.
- Carefully remove the old CR2032 battery from its holder.
- Insert a new CR2032 battery, ensuring correct polarity (+ side up).
- After replacing the battery, it is recommended to re-set the current time and date to ensure accuracy.
Caution: Only use non-rechargeable CR2032 batteries unless you have confirmed that your specific module variant is designed for rechargeable batteries and its charging circuit is properly configured.
6. Troubleshooting
- Module not responding via I2C:
- Check all wiring connections (GND, VCC, SDA, SCL) for proper contact and polarity.
- Verify that the I2C bus is enabled on your microcontroller.
- Confirm the correct I2C address (0x68 for DS3231) is being used in your code.
- Ensure the module is receiving adequate power (3.3V to 5.5V).
- Time is incorrect or not retained after power loss:
- Check if the CR2032 coin cell battery is present and correctly inserted.
- Replace the CR2032 battery with a new one.
- Verify that the battery charging circuit (if present) is disabled if using a non-rechargeable battery.
- Ensure the time is being set correctly by your microcontroller after initial power-up or battery replacement.
- Inaccurate timekeeping:
- While the DS3231 is highly accurate, extreme temperature fluctuations outside its specified range (-40°C to +85°C) can affect performance.
- Ensure the module is not exposed to excessive electrical noise.
- One of multiple modules not working:
- If you have multiple modules and one fails, it may be a manufacturing defect. Test with another module if available.
7. Specifications
| Feature | Specification |
|---|---|
| Model Name | DS3231 |
| Connectivity Technology | I2C |
| Operating Voltage | +2.3V to +5.5V |
| Timing Accuracy | ±5ppm (±0.432 s/day) over -40°C to +85°C |
| Temperature Sensor Accuracy | ±3°C |
| Clock Functions | Seconds, minutes, hours, day, date, month, year |
| Leap Year Compensation | Automatic up to 2100 |
| Output Frequencies | 1Hz, 32.768kHz |
| Compatible Devices | Raspberry Pi, Arduino, other microcontrollers |
8. Warranty and Support
Specific warranty information for the DORHEA DS3231 Real Time Clock Module is not provided in this document. For warranty claims or technical support, please refer to the retailer or manufacturer's official website where the product was purchased.