What Is a Real-Time Clock (RTC) Module? A 2026 Guide
Share
What Is a Real-Time Clock (RTC) Module? A 2026 Guide
A Real-Time Clock (RTC) is a tiny chip that keeps tracking the date and time — hours, minutes, seconds, day, month, year — even when your main board is powered off. It's the difference between "what time is it now?" and "what time was it at 3:47pm three weeks ago when that sensor spiked?"
Quick answer: Arduino/ESP32/Pico boards have no real clock — they count milliseconds with millis(), but forget the time once unplugged. An RTC module runs on its own coin cell, ticks along for years, and hands the current time to your board over I2C. The one to get is the DS3231 — industry-standard accuracy, roughly a minute of drift per year.
Proof of work: the explanation and code below are Soldr's actual answer to "What is a Real-Time Clock (RTC) Module and how do I use it?", asked through Compoden's AI build assistant on 12 August 2026. Published 12 August 2026 · Last updated 12 August 2026.
Why can't my board just keep time on its own?
Arduino, ESP32, and Pico boards have no real clock — they can count milliseconds with millis(), but the moment you unplug them, they forget what time it is entirely. An RTC module fixes this by running on its own coin cell (a CR2032) at a fraction of a milliamp, ticking along for years, and handing the current time to your microcontroller over I2C whenever asked. This matters for data loggers, timestamps in IoT logs, alarm clocks, and anything that needs to know the wall-clock time after a reboot.
| Property | DS3231 | Cheaper DS1307 |
|---|---|---|
| Accuracy | ±2ppm, temperature-compensated (~1 minute drift/year) | Drifts badly |
| Interface | I2C at address 0x68 | I2C |
| Voltage | Works on 3.3V or 5V (Arduino, ESP32, or Pi) | Typically 5V |
How do I actually set and read the time?
Using it is a three-step rhythm with the RTClib library (Arduino Library Manager → install "RTClib" by Adafruit): wire it up over I2C (four wires — power, ground, SDA, SCL), set the time once on first power-up or whenever the battery dies, then read it back whenever you need a timestamp. After that first rtc.adjust() call, the module owns the time and your board just reads it from then on.
void loop() {
DateTime now = rtc.now();
Serial.print(now.year()); Serial.print("-");
Serial.print(now.month()); Serial.print("-");
Serial.println(now.day());
Serial.printf("%02d:%02d:%02d\n",
now.hour(), now.minute(), now.second());
delay(1000);
}
This is the read-back half of the pattern from the same session's Firmware tab — the one-time rtc.adjust() setup call (typically rtc.adjust(DateTime(F(__DATE__), F(__TIME__))) in the standard RTClib pattern) runs once in setup(), before this loop.
Why does my RTC reset to a default date every time I unplug it?
The module has a socket for a CR2032 coin cell — if it's missing or dead, the clock loses power and resets to its default whenever the board is unplugged, which looks exactly like a wiring or code problem but isn't. Make sure a fresh CR2032 is actually seated in the socket; once it's there, the RTC keeps correct time independently of the main board's power state.
What do you need to try this yourself?
A DS3231 RTC Module (I2C, Battery Backup) (Rs.180) plus any of the boards it pairs with — an ESP32 Dev Board (Rs.400) or an Arduino Uno R3 (Rs.230) both work over I2C.
Frequently asked questions
RTC module ki zaroorat kyun padti hai?
Arduino ya ESP32 boards ke paas apna koi asli ghadi nahi hoti - unpower hote hi woh time bhool jaate hain. RTC module ek chhoti si coin cell battery par chalta hai aur saal tak sahi time yaad rakhta hai, chahe main board off hi kyun na ho - isliye data loggers aur timestamp waale projects mein zaroori hota hai.
Why is the DS3231 recommended over the cheaper DS1307 RTC?
The DS3231 has built-in temperature compensation, keeping it accurate to about a minute of drift per year, while the DS1307 drifts noticeably more without that compensation. For any project where the timestamp actually matters - a data logger, an alarm, an IoT log - the DS3231's small price difference is worth the accuracy.
What is the price of a DS3231 RTC module in India?
The DS3231 Real-Time Clock Module (I2C, Battery Backup) costs Rs.180 at Compoden, with cash on delivery available across India. It runs on 3.3V or 5V, so it pairs with an ESP32 (Rs.400) or an Arduino Uno (Rs.230) equally well. Prices checked 12 August 2026.
Do I need to set the RTC's time every time I power on my project?
No - you only call rtc.adjust() once, typically on first power-up or whenever the coin cell battery has been replaced. As long as the battery keeps the module powered between main-board power cycles, the RTC retains the correct time on its own and your board just reads it.