Rtc_Pcf8563 RTC Library for Arduino
Author:  Joe Robertson
Contact: orbitalair@bellsouth.net


Current version

1.0.3 2015-2-6: Added convenience call to individual getXYZ() functions. Added function test example.

1.0.1 2013-1-3: Merged below 1.1 with Arduino 1.0 modifications to Wire. 1.1 has no version() method, while 1.0.1 does. 1.1 is considered a fork.

1.1 2012-03-02: Square wave support, bug fixing and more alarm methods


  • 1.0 2010-10-13: Initial Release
  • 1.0.1 2013-1-3: Updated Release for Arduino. Adds methods and version id.
  • 1.0.2 purposely skipped this version.
  • 1.0.3 2015-2-6: Updated convenience functions. Added function test example.
  • 1.0.3 2015-2-21: Moved code to BitBucket since Playground won't let me upload anything.


Rtc_Pcf8563 RTC is a library for the Arduino.

This library will control all aspects of the PCF8563 Real Time Clock chip. This chip uses an external crystal and caps and has 1 Interrupt output. Output may also be configured for wave signal. Alarms can be set to trigger the interrupt.

The PCF8563 is battery backed.

Download, install and import

Current version: https://bitbucket.org/orbitalair/arduino_rtc_pcf8563/downloads

Please let me know via email if anyone cannot access bitbucket.

Previous version: Attach:Rtc_Pcf8563_1.0.1.zip

Forked Download here: https://github.com/elpaso/Rtc_Pcf8563
Older version: Attach:Rrc_Pcf8563-1.0.zip

Put the rtc_Pcf8563 folder in "hardware\libraries\".

In the Arduino IDE, create a new sketch (or open one) and

select from the menubar "Sketch->Import Library->Rtc_Pcf8563".
Once the library is imported, an "#include <Rtc_Pcf8563.h>" line will appear at the top of your sketch.



Remember to check your I2C addresses. There are set here, in the header file. And remember the games that Wire.h plays too!

/* the read and write values for pcf8563 rtcc */
/* these are adjusted for arduino */
#define RTCC_R  0xa3
#define RTCC_W  0xa2


To initialize the clock, in the setup() function do the following:

//clear out the registers
  //set a time to start with.
  //day, weekday, month, century(1=1900, 0=2000), year(0-99)
  rtc.setDate(14, 6, 3, 1, 10);
  //hr, min, sec
  rtc.setTime(1, 15, 0);


See the source for all methods.

void initClock

Zero out all values and disable all alarms.

void clearStatus()

Set both status bytes to zero.

void getDate()

Get date vals to local vars. Then use these calls to get specific values or use one of the formatDate/Time calls.

void setDate(byte day, byte weekday, byte month, byte century, byte year)

void getTime()

Get time vars + 2 status bytes to local vars.

void setTime(byte sec, byte minute, byte hour)

void setAlarm(byte min, byte hour, byte day, byte weekday)

Set alarm vals. Since 0(zero) is a valid input, use val=99 as 'ignore me' value in the alarm.

void clearAlarm()

Clear the alarm flag and interrupt.

char *formatTime(byte style=RTCC_TIME_HMS)

Get an output string, these call getTime/getDate for latest vals. Format Time has 2 style, HM (hh:mm), and HMS (hh:mm:ss).

char *formatDate(byte style=RTCC_DATE_US)

Date supports 3 styles as listed in the wikipedia page about world date/time. These are World, Asia, and US.


#include <Wire.h>
#include <Rtc_Pcf8563.h>

//init the real time clock
Rtc_Pcf8563 rtc;

void setup()
  //clear out the registers
  //set a time to start with.
  //day, weekday, month, century(1=1900, 0=2000), year(0-99)
  rtc.setDate(14, 6, 3, 1, 10);
  //hr, min, sec
  rtc.setTime(1, 15, 0);

void loop()
  //both format functions call the internal getTime() so that the
  //formatted strings are at the current time/date.


Information about this page

Last Modified: February 21, 2015, at 01:40 PM
By: Joe Robertson