Stufin
Home Quick Cart Profile

DS3231 Real Time Clock Memory Module with Battery (Pack of 25)

Buy Now on Stufin

Component Name

DS3231 Real Time Clock Memory Module with Battery (Pack of 25)

Overview

The DS3231 Real Time Clock (RTC) Memory Module is a highly accurate and reliable time-keeping device designed for a wide range of IoT applications. This module combines a real-time clock, memory, and a rechargeable battery in a compact package, making it an ideal choice for devices that require precise timing and low power consumption. This pack of 25 modules is suitable for prototyping, development, and mass production.

Functionality

The DS3231 RTC Memory Module is a plug-and-play device that provides the following functionalities
Real-Time ClockThe module accurately keeps track of time, including seconds, minutes, hours, days, months, and years, with an accuracy of 2 ppm (parts per million). It also supports automatic daylight saving time (DST) adjustments.

Memory

The module features 236 bytes of non-volatile memory, allowing users to store small amounts of data, such as configuration settings, calibration data, or other application-specific information.

Battery Backup

The module is equipped with a rechargeable CR2032 lithium-ion battery, which provides backup power to the RTC and memory in the event of a main power failure. The battery life can last up to 10 years in typical usage scenarios.

I2C InterfaceThe module communicates with the host system through a standard I2C (Inter-Integrated Circuit) interface, making it easy to integrate with microcontrollers, single-board computers, and other devices.

Key Features

  • High Accuracy: 2 ppm accuracy ensures precise timekeeping, even in extreme temperatures.
  • Low Power Consumption: The module operates at a low voltage (1.8 V to 5.5 V) and consumes minimal power (typically 1.5 A) in standby mode.
  • Wide Operating Temperature: The module operates reliably in temperatures ranging from -40C to 85C.
  • Battery-Backed Memory: The module's memory is retained even when the main power is interrupted, ensuring that stored data remains intact.
  • Automatic DST Adjustment: The module automatically adjusts for daylight saving time, eliminating the need for manual adjustments.
  • Compact Design: The module is compact and lightweight, making it suitable for small form factor designs.
  • Easy Integration: The I2C interface ensures easy integration with a wide range of host systems.

Technical Specifications

| Parameter | Value |

| --- | --- |

| Supply Voltage | 1.8 V to 5.5 V |

| Operating Temperature | -40C to 85C |

| Accuracy | 2 ppm |

| Clock Frequency | 32.768 kHz |

| Memory Capacity | 236 bytes |

| Battery Life | Up to 10 years (typical) |

| Interface | I2C (Inter-Integrated Circuit) |

| Dimensions | 25.4 mm 20.3 mm 4.5 mm |

Packaging and Order Information

Pack of 25 modules

Each module is individually packaged and labeled for easy identification

Modules are shipped in anti-static packaging to prevent damage during transportation

Applications

The DS3231 Real Time Clock Memory Module with Battery is suitable for a wide range of IoT applications, including

Wearable devices

Industrial automation systems

Medical devices

Automotive systems

Consumer electronics

Robotics and drones

Smart home devices

Pin Configuration

  • DS3231 Real Time Clock Memory Module with Battery
  • The DS3231 is a highly accurate, low-power, real-time clock (RTC) module that provides a battery-backed clock and 236 bytes of battery-backed SRAM. It is ideal for use in a wide range of applications, including IoT devices, automation systems, and embedded systems.
  • Pinout Description
  • The DS3231 module has a total of 16 pins, which are divided into two rows of 8 pins each. Below is a detailed description of each pin:
  • Row 1 (Left to Right)
  • 1. VCC: Power supply pin for the module. Typically connected to a 3.3V or 5V power source.
  • 2. GND: Ground pin. Connected to the ground of the circuit.
  • 3. SCL: Serial Clock pin for I2C communication. Connected to the SCL pin of the microcontroller.
  • 4. SDA: Serial Data pin for I2C communication. Connected to the SDA pin of the microcontroller.
  • 5. RST: Reset pin. Active low, connected to a digital output of the microcontroller or a reset button.
  • 6. 32K: 32.768 kHz clock output pin. Can be used as a clock source for other components.
  • 7. SQW: Square Wave output pin. Can be used to generate a square wave signal.
  • 8. VBAT: Battery input pin. Connected to a 3V Lithium battery (included) or an external battery source.
  • Row 2 (Left to Right)
  • 1. NC: Not Connected. No internal connection.
  • 2. INT/SQ: Interrupt/Square Wave output pin. Can be used as an interrupt output or a square wave output.
  • 3. RS: Rising Edge Trigger input pin. Used for alarm functions.
  • 4. FOUT: Output frequency pin. Can be configured to output 1Hz, 4kHz, 8kHz, or 32kHz.
  • 5. A0: Address pin for I2C communication. Typically connected to GND or VCC.
  • 6. A1: Address pin for I2C communication. Typically connected to GND or VCC.
  • 7. NC: Not Connected. No internal connection.
  • 8. NC: Not Connected. No internal connection.
  • Connection Structure
  • When connecting the DS3231 module to a microcontroller or a development board, follow this structure:
  • VCC to 3.3V or 5V power source
  • GND to Ground
  • SCL to SCL pin of the microcontroller
  • SDA to SDA pin of the microcontroller
  • RST to a digital output of the microcontroller or a reset button
  • VBAT to a 3V Lithium battery (included) or an external battery source
  • Optional connections:
  • 32K to a clock input of another component
  • SQW to a digital input of the microcontroller
  • INT/SQ to a digital input of the microcontroller
  • RS to a digital output of the microcontroller
  • FOUT to a clock input of another component
  • A0 and A1 to GND or VCC for I2C address configuration
  • Note: The NC pins should be left unconnected.
  • Important
  • Ensure the DS3231 module is powered with a stable voltage source (3.3V or 5V) to maintain accurate clock performance.
  • Use a suitable pull-up resistor (e.g., 4.7k) for the I2C lines (SCL and SDA) to prevent signal degradation.
  • Follow the datasheet and application notes for specific implementation details and programming requirements.

Code Examples

DS3231 Real Time Clock Memory Module with Battery
Overview
The DS3231 Real Time Clock (RTC) module is a widely used component in IoT projects that requires accurate timekeeping and battery backup. This module is based on the DS3231 IC, a highly accurate RTC with an integrated temperature-compensated crystal oscillator (TCXO) and a battery-backed RTC. The module also features a 32.768 kHz crystal oscillator, which provides a stable clock signal.
Features
High accuracy RTC with 2 ppm at 25C
 Battery-backed RTC with a CR2032 battery holder
 32.768 kHz crystal oscillator
 I2C communication interface
 236 bytes of NV RAM for data storage
 Operating temperature range: -40C to 85C
Pinout
| Pin | Function |
| --- | --- |
| VCC | Power supply (3.3V - 5V) |
| GND | Ground |
| SCL | I2C clock signal |
| SDA | I2C data signal |
| SQW | Square wave output pin (can be used as an interrupt) |
| 32K | 32.768 kHz clock signal output |
Code Examples
### Example 1: Basic RTC Operation with Arduino
This example demonstrates how to use the DS3231 RTC module with an Arduino board to set and read the current time.
```c++
#include <DS3231.h>
DS3231 rtc;
void setup() {
  Serial.begin(9600);
  rtc.begin(); // Initialize the RTC module
}
void loop() {
  // Set the current time
  rtc.set_time(12, 34, 56, 1, 1, 2023); // Set time to 12:34:56, January 1, 2023
// Read the current time
  DateTime now = rtc.get_time();
  Serial.print("Current time: ");
  Serial.print(now.hour, DEC);
  Serial.print(":");
  Serial.print(now.minute, DEC);
  Serial.print(":");
  Serial.print(now.second, DEC);
  Serial.println();
delay(1000);
}
```
### Example 2: Using the SQW Pin as an Interrupt with Raspberry Pi
This example demonstrates how to use the SQW pin as an interrupt with a Raspberry Pi to trigger an event every minute.
```python
import RPi.GPIO as GPIO
import time
import datetime
# Set up the GPIO library
GPIO.setmode(GPIO.BCM)
# Set up the SQW pin as an input
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def isr_sqw(channel):
    print("Interrupt triggered at", datetime.datetime.now())
GPIO.add_event_detect(17, GPIO.RISING, callback=isr_sqw, bouncetime=100)
while True:
    time.sleep(1)
```
### Example 3: Reading and Writing to the NV RAM with ESP32
This example demonstrates how to read and write data to the NV RAM of the DS3231 RTC module using an ESP32 board.
```c++
#include <Wire.h>
#include <DS3231.h>
DS3231 rtc;
void setup() {
  Serial.begin(9600);
  Wire.begin(); // Initialize the I2C interface
  rtc.begin(); // Initialize the RTC module
}
void loop() {
  // Write a string to the NV RAM
  char data[] = "Hello, World!";
  rtc.write_nv_ram(0, data, sizeof(data));
// Read the string from the NV RAM
  char buffer[16];
  rtc.read_nv_ram(0, buffer, sizeof(buffer));
  Serial.println("Data read from NV RAM: ");
  Serial.println(buffer);
delay(1000);
}
```
Note: In each example, make sure to connect the DS3231 RTC module to the microcontroller or board according to the pinout diagram and configure the I2C communication interface correctly.