ArrowtronElectronics Store
Free shipping over ₹999
100% genuine components
Dispatch in 1–2 days
Secure payments · UPI, Cards

Always-Accurate Digital Clock with DS3231 RTC and 16×2 LCD

Build a clock that keeps perfect time even through power cuts, thanks to the battery-backed DS3231 real-time clock module.

Beginner~1 hour5 components

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

ComponentQtyPrice
Arduino Nano ATmega328P Compatible Board1₹149
RTC DS32311₹89
16×2 LCD Display1₹39
10K Potentiometer1₹249
400 Point Breadboard1₹299
Total₹825

Step-by-step guide

  1. Wire the DS3231 over I2C: VCC to 5V, GND to GND, SDA to A4, SCL to A5.
  2. 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.
  3. Install the “RTClib” library by Adafruit.
  4. Upload once with the rtc.adjust line uncommented — it sets the RTC from your computer’s clock at compile time.
  5. Comment that line out and upload again, so the time isn’t reset on every boot.
  6. 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
Scroll to Top