Header Ads

Header ADS

DIY RTC Digital Clock with Professional PCB Design

 DIY RTC Digital Clock with Professional PCB Design

$5 10pcs 1-2 layer PCB Order from PCBWay: https://www.pcbway.com/?from=technology4power


Introduction

In this blog post, we will guide you through making a DIY RTC Digital Clock using an Arduino UNO and an I2C LCD. We will also explain the provided circuit diagram, how to design and order a PCB from PCBWay, and why PCBWay is the best choice for high-quality PCBs.

Circuit Diagram Explanation

The schematic consists of an ATmega328P microcontroller, an RTC module, an I2C LCD, and other supporting components. The microcontroller manages the real-time clock functionality and displays the time on the LCD screen.


Key Components Used:

  1. Microcontroller: ATmega328P-PU

  1. Real-Time Clock Module: DS3231

  2. Display: 16x2 LCD with I2C interface

  3. Voltage Regulator: 7805 for 5V regulation

  4. Diodes: 1N4007 for reverse polarity protection

  5. Transistors: BC547B for switching

  6. Capacitors: 22pF and 220uF for stability

  7. Resistors: 10kΩ, 1kΩ

  8. Crystal Oscillator: 16MHz

  9. Relay Module: For controlling external devices

  10. LED Indicators: For power and status indication


Hardware Connections & Explanation

  1. I2C LCD: The I2C LCD is connected to the ATmega328P microcontroller via SDA (A4) and SCL (A5) lines. This reduces the number of GPIO pins required for communication.

  1. RTC Module: The DS3231 RTC module communicates via I2C and provides accurate timekeeping.

  2. Power Supply: The circuit operates at 5V, regulated by the 7805 voltage regulator.

  3. Relay Control: The relay is controlled by a transistor to switch external loads.


Working Principle

  1. The RTC module keeps track of the real-time clock and communicates with the microcontroller via I2C.

  2. The microcontroller reads the time data and displays it on the LCD.

  3. A relay is incorporated to control external devices based on time settings.

  4. The system is powered by a stable 5V regulated supply to ensure smooth operation.


How the RTC Module Works & Calibration

The DS3231 RTC module is a highly accurate real-time clock with an inbuilt temperature-compensated crystal oscillator. It maintains time even when power is removed, thanks to its onboard battery backup.

Calibration with Arduino UNO

  1. Connect the RTC Module to Arduino:

  2. VCC → 5V

  3. GND → GND

  4. SDA → A4
  1. SCL → A5

  1. Upload the following code to set the correct time:

#include <Wire.h>
#include <RTClib.h>

RTC_DS3231 rtc;

void setup() {
  Serial.begin(9600);
  if (!rtc.begin()) {
    Serial.println("RTC not found!");
    while (1);
  }
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  Serial.println("RTC Set to Compilation Time");
}

void loop() {}
  1. Verify RTC Time: Upload the code below to read and display the RTC time.

void loop() {
  DateTime now = rtc.now();
  Serial.print(now.year(), DEC);
  Serial.print("/");
  Serial.print(now.month(), DEC);
  Serial.print("/");
  Serial.print(now.day(), DEC);
  Serial.print(" ");
  Serial.print(now.hour(), DEC);
  Serial.print(":");
  Serial.print(now.minute(), DEC);
  Serial.print(":");
  Serial.println(now.second(), DEC);
  delay(1000);
}

Arduino Code for RTC Digital Clock

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <RTClib.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);
RTC_DS3231 rtc;

void setup() {
  lcd.begin();
  lcd.backlight();
  if (!rtc.begin()) {
    lcd.print("RTC ERROR");
    while (1);
  }
  rtc.adjust(DateTime(__DATE__, __TIME__)); // Set to compile time
}

void loop() {
  DateTime now = rtc.now();
  lcd.setCursor(0, 0);
  lcd.print("Time: ");
  lcd.print(now.hour(), DEC);
  lcd.print(":");
  lcd.print(now.minute(), DEC);
  lcd.print(":");
  lcd.print(now.second(), DEC);
  delay(1000);
}

Code Explanation

  1. RTC Initialization: The DS3231 module is initialized using the RTClib library.
  2. LCD Display: The I2C LCD module displays real-time clock data.
  3. Time Adjustment: The RTC is set to the current compile time when the program is uploaded.
  4. Loop Function:

  1. Continuously reads the RTC time.

  1. Displays the time on the LCD.

  2. Refreshes every second to keep it updated.


PCB Design & Ordering from PCBWay

$5 10pcs 1-2 layer PCB Order from PCBWay: https://www.pcbway.com/?from=technology4power


Steps to Design PCB:

  1. Schematic Capture: Use EasyEDA or any PCB design software to create the schematic.

  2. PCB Layout: Convert the schematic into a PCB layout, placing components efficiently.

  3. Gerber File Export: Generate Gerber files for manufacturing.

Ordering from PCBWay

  1. Visit www.pcbway.com

  2. Upload your Gerber files

  3. Select specifications (e.g., layer count, thickness, color)

  4. Place your order and receive high-quality PCBs in days!

Why Choose PCBWay?

  1. High-quality PCBs with professional finishing

  1. Affordable pricing with bulk discounts

  2. Quick turnaround and fast shipping

  3. Customizable board design with multiple color options

  4. Reliable customer support and engineering assistance

Video Reference:

$5 10pcs 1-2 layer PCB Order from PCBWay: https://www.pcbway.com/?from=technology4power


Conclusion

By following this guide, you can build a professional RTC Digital Clock using an Arduino UNO and an I2C LCD. This project provides a practical way to understand RTC communication, LCD interfacing, and relay control. Using PCBWay for PCB manufacturing ensures high quality and reliability. Happy DIYing!



No comments

Theme images by Bim. Powered by Blogger.