Build a clock that keeps perfect time even through power cuts, thanks to the battery-backed DS3231 real-time clock module.
What you’ll build
The DS3231 is a temperature-compensated RTC accurate to about a minute per year, and its coin cell keeps time with the power off. The Arduino Nano reads it over I2C and prints time and date on a 16×2 character LCD.
Components you’ll need
| Component | Qty | Price |
|---|---|---|
| Arduino Nano ATmega328P Compatible Board | 1 | ₹149 |
| RTC DS3231 | 1 | ₹89 |
| 16×2 LCD Display | 1 | ₹39 |
| 10K Potentiometer | 1 | ₹249 |
| 400 Point Breadboard | 1 | ₹299 |
| Total | ₹825 |
Step-by-step guide
- Wire the DS3231 over I2C: VCC to 5V, GND to GND, SDA to A4, SCL to A5.
- Connect the LCD in 4-bit mode: RS→D12, E→D11, D4–D7→D5,D4,D3,D2; wire the 10K potentiometer to pin V0 for contrast.
- Install the “RTClib” library by Adafruit.
- Upload once with the rtc.adjust line uncommented — it sets the RTC from your computer’s clock at compile time.
- Comment that line out and upload again, so the time isn’t reset on every boot.
- Unplug everything for a minute and power up again — the clock should still be spot on.
The code
RTClib does the heavy lifting; the loop just formats the time onto the LCD once a second.
#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal.h>
RTC_DS3231 rtc;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup(){
lcd.begin(16, 2); rtc.begin();
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // run ONCE, then comment out
}
void loop(){
DateTime now = rtc.now();
char line1[17], line2[17];
sprintf(line1, " %02d:%02d:%02d", now.hour(), now.minute(), now.second());
sprintf(line2, " %02d/%02d/%04d", now.day(), now.month(), now.year());
lcd.setCursor(0,0); lcd.print(line1);
lcd.setCursor(0,1); lcd.print(line2);
delay(1000);
}Build this project
Add all 5 required components to your cart in one click — total ₹825.
Add all components to cart