

The ZS-042 RTC Module is a real-time clock (RTC) module designed to keep track of the current time and date. It is built around the DS3231 chip, a highly accurate RTC with an integrated temperature-compensated crystal oscillator. The module communicates with microcontrollers via the I2C interface, making it easy to integrate into a variety of projects. Additionally, it features a battery backup, ensuring that the timekeeping functionality continues even when the main power supply is disconnected.








The ZS-042 RTC Module has a 4-pin header for I2C communication. The pinout is as follows:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply input (3.3V or 5V) |
| 2 | GND | Ground |
| 3 | SDA | Serial Data Line for I2C communication |
| 4 | SCL | Serial Clock Line for I2C communication |
RTClib library in Arduino IDE for easy communication with the module.#include <Wire.h>
#include <RTClib.h>
// Create an RTC object
RTC_DS3231 rtc;
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud
Wire.begin(); // Initialize I2C communication
if (!rtc.begin()) {
Serial.println("Couldn't find RTC module!");
while (1); // Halt the program if the RTC is not detected
}
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 date and time
// Print the current date and time 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 Module Not Detected
Incorrect Time Displayed
rtc.adjust() function to set the correct time.No Output on Serial Monitor
Serial.begin(9600) is called in the setup() function and the Serial Monitor is set to 9600 baud.Battery Backup Not Working
Q: Can the ZS-042 RTC Module work with 3.3V microcontrollers?
A: Yes, the module is compatible with both 3.3V and 5V systems.
Q: How long does the backup battery last?
A: A typical CR2032 battery can last several years, depending on usage and environmental conditions.
Q: Can I use the module without a backup battery?
A: Yes, but the time will reset whenever the main power is disconnected.
Q: Does the module support alarms?
A: Yes, the DS3231 chip supports alarms, but additional programming is required to use this feature.
This concludes the documentation for the ZS-042 RTC Module.