DS3231 RTC Tutorial

In this Project, we will see about how to interface DS3231 RTC Module with Arduino.

Circuit Diagram:

Arduino Code:
rtc_lcd_code.ino
//This Code is Developed by Sdev
//Follow Us Here : https://youtube.com/sdevelectronics

#include <DS3231.h>
#include <LiquidCrystal.h>

DS3231  rtc(SDA, SCL);
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

void setup() {
  rtc.begin();
  lcd.begin(16, 2);
}

void loop() {
  lcd.setCursor(0, 0);
  lcd.print("Time:  ");
  lcd.print(rtc.getTimeStr());

  lcd.setCursor(0, 1);
  lcd.print("Date: ");
  lcd.print(rtc.getDateStr());
  delay (1000);
}

rtc_led_control_code.ino
//This Code is Developed by Sdev
//Follow Us Here : https://youtube.com/sdevelectronics

#include <DS3231.h>
#include <LiquidCrystal.h>

DS3231  rtc(SDA, SCL);
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

void setup() {
  rtc.begin();
  lcd.begin(16, 2);
  pinMode(13, OUTPUT);
}

void loop() {
  lcd.setCursor(0, 0);
  lcd.print("Time:  ");
  lcd.print(rtc.getTimeStr());
  lcd.setCursor(0, 1);
  lcd.print("Date: ");
  lcd.print(rtc.getDateStr());

  String current_time = rtc.getTimeStr();
  if (current_time.equals("02:29:00")) {
    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
  }
  delay (1000);
}

Library Used:

Youtube Video Tutorial:




Download our official Android App in PlayStore. Click Here
You can get the all the required files (like Circuit Diagram, Arduino.ino file, Libraries Used, and others) for the project  in ZIP format and much more...

No comments:

Post a Comment