DS3231 Real Time Clock Memory Module with Battery (Pack of 25)
DS3231 Real Time Clock Memory Module with Battery (Pack of 25)
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.
| The DS3231 RTC Memory Module is a plug-and-play device that provides the following functionalities | |
| Real-Time Clock | The 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. |
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.
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 Interface | The 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. |
| 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 |
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
| 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
DS3231 Real Time Clock Memory Module with BatteryOverviewThe 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.FeaturesHigh 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 85CPinout| 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 ArduinoThis 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 PiThis 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 ESP32This 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.