Tutorial 16: Arduino Clock

Summary of Tutorial 16: Arduino Clock


This tutorial explains how to build an Arduino clock displaying time and date via an optional LCD and serial monitor, using the PCF8563 real-time clock IC. Users can set time/date through the Arduino serial monitor. The project includes an optional battery backup to preserve settings when power is off. It covers required components, circuit diagrams, and interfacing with LCD plus programming details. The sketch can be downloaded, and time/date adjustments are done through serial commands. The design supports adding a battery backup and an HD44780 compatible LCD for display.

Parts used in the Arduino Clock:

  • Arduino Uno board
  • USB cable
  • Wire links
  • Breadboard
  • 2 x 2k2 resistors (red - red - red)
  • 100nF non-polarized capacitor
  • 32.768kHz watch crystal
  • PCF8563P real time clock IC
  • 2 x 1N4148 diodes (for battery backup)
  • CR2032 coin battery holder
  • 3V CR2032 battery
  • 47 ohm resistor (yellow - violet - black) (for LCD)
  • 10k potentiometer (trimpot or panel mount for LCD)
  • MSC-C162DYLY-4N, PC1602LRS-FWA-B, or similar HD44780 compatible 16x2 LCD display

In this tutorial, the Arduino displays the time and date on a LCD (optional) and in the Arduino IDE serial monitor window. A PCF8563 real time clock (RTC) IC is used to generate the time and date.

The time and date can be set using the Arduino serial monitor window. An optional battery can be used to back up the time and date settings in the real time clock chip so that the time and date are not lost if the Arduino power is unplugged.

Prerequisites

Preferably you should follow all the beginner tutorials in order, but as a minimum: if using a LCD display, complete Tutorial 12: Arduino LCD. You should know how to use an 8 pin IC, e.g. from tutorial 5.

Read about crystals and coin batteries.

Components

Arduino Uno board, USB cable, wire links and a breadboard.

To just build the clock circuit you will need:

QtyPartDesignatorNotesType
22k2 resistors (red – red – red)R1, R21/4W 5% or betterResistors
1100nC1Non-polarizedCapacitor
132.768kHz crystalX132.768kHz watch crystalCrystal
1PCF8563PU1Real time clock ICSemiconductor

Tutorial 16 Arduino ClockFrom amazon.com:

32.768kHz Watch Crystals

To add the battery backup for the real time clock IC, you will need:

QtyPartDesignatorNotesType
21N4148D1, D21N4148 diodesSemiconductor
1CR2032 coin battery holderBT1Battery holder
13V CR2032 batteryBT1Battery

To use a LCD to display the time and date, you will need:

QtyPartDesignatorNotesType
147 ohm resistor (yellow – violet – black)1/4W 5% or betterResistor
110k potentiometerTrimpot or panel mountPotentiometer
1MSC-C162DYLY-4N (Truly), PC1602LRS-FWA-B (Powertip) or similar HD44780 compatible LCD16 character by 2 line LCD displayLCD

Circuit Diagram

Two circuit diagrams are shown. The first shows only the RTC chip (PCF8563) connected to the Arduino. The second circuit diagram shows the optional battery backup added. To add the LCD, follow tutorial 12

Tutorial 16: Arduino Clock

 In this tutorial, the Arduino displays the time and date on a LCD (optional) and in the Arduino IDE serial monitor window. A PCF8563 real time clock (RTC) IC is used to generate the time and date.

The time and date can be set using the Arduino serial monitor window. An optional battery can be used to back up the time and date settings in the real time clock chip so that the time and date are not lost if the Arduino power is unplugged.

Prerequisites

Preferably you should follow all the beginner tutorials in order, but as a minimum: if using a LCD display, complete Tutorial 12: Arduino LCD. You should know how to use an 8 pin IC, e.g. from tutorial 5.

Read about crystals and coin batteries.

Components

Arduino Uno board, USB cable, wire links and a breadboard.

To just build the clock circuit you will need:

QtyPartDesignatorNotesType
22k2 resistors (red – red – red)R1, R21/4W 5% or betterResistors
1100nC1Non-polarizedCapacitor
132.768kHz crystalX132.768kHz watch crystalCrystal
1PCF8563PU1Real time clock ICSemiconductor

From amazon.com:

32.768kHz Watch Crystals

To add the battery backup for the real time clock IC, you will need:

QtyPartDesignatorNotesType
21N4148D1, D21N4148 diodesSemiconductor
1CR2032 coin battery holderBT1Battery holder
13V CR2032 batteryBT1Battery

To use a LCD to display the time and date, you will need:

QtyPartDesignatorNotesType
147 ohm resistor (yellow – violet – black)1/4W 5% or betterResistor
110k potentiometerTrimpot or panel mountPotentiometer
1MSC-C162DYLY-4N (Truly), PC1602LRS-FWA-B (Powertip) or similar HD44780 compatible LCD16 character by 2 line LCD displayLCD

Circuit Diagram

Two circuit diagrams are shown. The first shows only the RTC chip (PCF8563) connected to the Arduino. The second circuit diagram shows the optional battery backup added. To add the LCD, follow tutorial 12.

Arduino Clock Circuit

Arduino Clock Circuit with Battery Backup

Building the Circuit

First interface the PCF8563 to the Arduino as shown in the first circuit diagram above. The PCF8563 is packaged in an 8 pin DIP (Dual In-line Package). The circuit can then be tested using the Arduino IDE serial monitor window as explained in the sections below.

Interface the LCD next as per Tutorial 12: Arduino LCD. Use the same circuit diagram and connections for the LCD as shown in the tutorial.

The battery backup circuit can be added at any time.

The complete breadboard circuit with LCD and battery backup is shown below. Click the picture for a bigger image.Tutorial 16 Arduino Clock Schematic

Programming the Arduino

The clock sketch is too long to list here, so download the clock.zip file that contains the Arduino sketch for this project. Copy the clock folder from the zipped file to your Arduino sketchbook folder. Alternatively, copy the text from the enclosed file and paste it into the Arduino IDE. Verify and upload the clock sketch to the Arduino.

Operating the Circuit

If a LCD is interfaced to the Arduino and the clock sketch is loaded, the time and date should be displayed on the LCD immediately. Open the Arduino serial monitor window to see the time and date displayed and updated every second. The time and date can be set as described below.

Changing the Time and Date

When the Arduino serial monitor window is open, the time and date can be set by sending ‘s’ to the Arduino. The image below shows the menu that is displayed in the serial monitor window after sending the ‘s’ character.

 

For more detail: Tutorial 16: Arduino Clock

 


About The Author

Image

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top