Target Amount: $133 / $2000
Amount Raised will be updated once daily.
Thanks to those who have donated.
Starting Electronics Fund Raiser
It is that time of the year again when our annual web hosting subscription must be paid.
We also need to upgrade our lab equipment which is outdated (including test equipment).
Please consider giving a donation to Starting Electronics and help to fund this site.
Created on: 6 August 2012
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.
Can't see the video? View on YouTube →
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.
Arduino Uno board, USB cable, wire links and a breadboard.
To just build the clock circuit you will need:
|2||2k2 resistors (red - red - red)||R1, R2||1/4W 5% or better||Resistors|
|1||32.768kHz crystal||X1||32.768kHz watch crystal||Crystal|
|1||PCF8563P||U1||Real time clock IC||Semiconductor|
To add the battery backup for the real time clock IC, you will need:
|2||1N4148||D1, D2||1N4148 diodes||Semiconductor|
|1||CR2032 coin battery holder||BT1||Battery holder|
|1||3V CR2032 battery||BT1||Battery|
To use a LCD to display the time and date, you will need:
|1||47 ohm resistor (yellow - violet - black)||1/4W 5% or better||Resistor|
|1||10k potentiometer||Trimpot or panel mount||Potentiometer|
|1||MSC-C162DYLY-4N (Truly), PC1602LRS-FWA-B (Powertip) or similar HD44780 compatible LCD||16 character by 2 line LCD display||LCD|
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.
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.
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.
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.
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.
After the menu is showing, select what you want to change from the menu. E.g. to change the hour value of the time, send '4' and you will be prompted to send the new time. Always send two numbers for any setting, i.e. don't send 2 to set the hour to 2, send 02. Change as many parameters as you want and then send '7' to write all the changes in one go.
The video below demonstrates changing the year parameter of the date.
Can't see the video? View on YouTube →
Some people are experiencing problems with this tutorial. This tutorial seems to work on some hardware, but not on others – this problem still needs to be resolved.
If you are having trouble with getting the sketch to work then go to the Testing the PCF8563 Real Time Clock IC using Arduino article to do some testing / fault finding. Go to the Blog entry for this article for help and to report any problems.
© 2012 – 2014, Starting Electronics