Tekko BDSimSimulatorProjects

DS3231 RTC ঘড়ি (বিদ্যুৎ না থাকলেও সময় মনে রাখে)Digital Clock Arduino (DS3231 RTC + LCD)

DS3231 এর নিজের coin cell আর temperature-compensated crystal আছে, তাই Arduino বন্ধ থাকলেও সময় ঠিক থাকে। millis() দিয়ে বানানো ঘড়ি প্রতিবার power দিলে রিসেট হয় — তাই আসল ঘড়িতে RTC লাগে।

The DS3231 has its own coin cell and a temperature-compensated crystal, so it keeps time with the Arduino switched off. A millis() clock drifts and resets every power cycle — that is why a real clock uses an RTC.

▶ ফ্রি চালিয়ে দেখো / Run it free Parts অর্ডার করো (WhatsApp)

সার্কিট ডায়াগ্রাম · Circuit diagram

Digital Clock Arduino (DS3231 RTC + LCD) circuit diagram — Arduino Uno, Clock module (DS3231 RTC), LCD 16x2 with I2C, Jumper wires

যা যা লাগবে · Parts you need

তার লাগানো · Wiring

Clock module (DS3231 RTC) VCC→Arduino Uno 5V
Clock module (DS3231 RTC) GND→Arduino Uno GND
Clock module (DS3231 RTC) SDA→Arduino Uno A4
Clock module (DS3231 RTC) SCL→Arduino Uno A5
LCD 16x2 with I2C VCC→Arduino Uno 5V
LCD 16x2 with I2C GND→Arduino Uno GND
LCD 16x2 with I2C SDA→Arduino Uno A4
LCD 16x2 with I2C SCL→Arduino Uno A5

Code (Arduino C++)

#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
// Digital clock: the DS3231 has its own coin cell and a temperature-compensated
// crystal, so it keeps time even when the Arduino is off — a plain millis() clock
// resets every time. RTClib reads it over I2C.
RTC_DS3231 rtc;
LiquidCrystal_I2C lcd(0x27, 16, 2);
char days[7][12] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};

void setup() {
  Serial.begin(9600);
  if (!rtc.begin()) { Serial.println("DS3231 not found"); while (1) delay(10); }
  lcd.init();
  lcd.backlight();
  // run this line ONCE to set the clock to when the sketch was compiled:
  // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}

void loop() {
  DateTime now = rtc.now();
  lcd.setCursor(0, 0);
  lcd.print(now.day()); lcd.print('/'); lcd.print(now.month()); lcd.print('/');
  lcd.print(now.year()); lcd.print(' '); lcd.print(days[now.dayOfTheWeek()]);
  lcd.setCursor(0, 1);
  if (now.hour() < 10) lcd.print('0');
  lcd.print(now.hour()); lcd.print(':');
  if (now.minute() < 10) lcd.print('0');
  lcd.print(now.minute()); lcd.print(':');
  if (now.second() < 10) lcd.print('0');
  lcd.print(now.second());
  Serial.print(now.year()); Serial.print('/'); Serial.print(now.month()); Serial.print('/');
  Serial.print(now.day()); Serial.print(' ');
  Serial.print(now.hour()); Serial.print(':'); Serial.print(now.minute()); Serial.print(':');
  Serial.println(now.second());
  delay(500);
}

আরো project · More projects