DIY RTC Digital Clock with Professional PCB Design
DIY RTC Digital Clock with Professional PCB Design
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:
- Microcontroller: ATmega328P-PU
Real-Time Clock Module: DS3231
Display: 16x2 LCD with I2C interface
Voltage Regulator: 7805 for 5V regulation
Diodes: 1N4007 for reverse polarity protection
Transistors: BC547B for switching
Capacitors: 22pF and 220uF for stability
Resistors: 10kΩ, 1kΩ
Crystal Oscillator: 16MHz
Relay Module: For controlling external devices
LED Indicators: For power and status indication
Hardware Connections & Explanation
- 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.
RTC Module: The DS3231 RTC module communicates via I2C and provides accurate timekeeping.
Power Supply: The circuit operates at 5V, regulated by the 7805 voltage regulator.
Relay Control: The relay is controlled by a transistor to switch external loads.
Working Principle
The RTC module keeps track of the real-time clock and communicates with the microcontroller via I2C.
The microcontroller reads the time data and displays it on the LCD.
A relay is incorporated to control external devices based on time settings.
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
Connect the RTC Module to Arduino:
VCC → 5V
GND → GND
- SDA → A4
- SCL → A5
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() {}
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
- RTC Initialization: The DS3231 module is initialized using the RTClib library.
- LCD Display: The I2C LCD module displays real-time clock data.
- Time Adjustment: The RTC is set to the current compile time when the program is uploaded.
Loop Function:
- Continuously reads the RTC time.
Displays the time on the LCD.
Refreshes every second to keep it updated.
PCB Design & Ordering from PCBWay
Steps to Design PCB:
Schematic Capture: Use EasyEDA or any PCB design software to create the schematic.
PCB Layout: Convert the schematic into a PCB layout, placing components efficiently.
Gerber File Export: Generate Gerber files for manufacturing.
Ordering from PCBWay
Visit www.pcbway.com
Upload your Gerber files
Select specifications (e.g., layer count, thickness, color)
Place your order and receive high-quality PCBs in days!
Why Choose PCBWay?
- High-quality PCBs with professional finishing
Affordable pricing with bulk discounts
Quick turnaround and fast shipping
Customizable board design with multiple color options
Reliable customer support and engineering assistance
Video Reference:
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