Contents

Interfacing PCF8563 Real Time Clock RTC Module with Arduino

PCF8563 RTC Module Features

The PCF8563 real time clock module features high accuracy and low power consumption. This RTC maintains seconds, minutes, hours, day, date, month, and year information. In this module, the date is set based on whether the month is 29, 30 or 31 days and also it is leap year or not. This module can also be used in 12-hour and 24-hour formats.

DS3231 RTC Module Pinout

This module has 6 pins:

  • INT: interrupt output
  • COT: Clock output
  • SCL: Serial Clock Input for I2C protocol
  • SDA: Serial Data Input / Output for I2C protocol
  • GND: Ground
  • VCC: Module power supply – 5V

You can see the pinout of this module in the image below.

Required Materials

Hardware Components

Arduino UNO R3 × 1
PCF8563 Real Time Clock Module × 1
Male to Female jumper wire × 1

Software Apps

Arduino IDE

Interfacing PCF8563 RTC Module with Arduino

Step 1: Circuit

The following circuit shows how you should connect Arduino to PCF8563 module. Connect wires accordingly.

Step 2: Installing Library

Go to Library manager and install the Rtc_Pcf8563 library.

Tip

If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library

Step 3: Code

Upload the following code to Arduino. After that open Serial Monitor.

 /*  
modified on Nov 16, 2020
Modified by MehranMaleki from Arduino Examples
Home
*/ #include <Wire.h> #include <Rtc_Pcf8563.h> //init the real-time clock Rtc_Pcf8563 rtc; void setup() { Serial.begin(9600); Wire.begin(); //clear out all the registers rtc.initClock(); //set a time to start with. //day, weekday, month, century, year rtc.setDate(16, 3, 11, 20, 20); //hr, min, sec rtc.setTime(11, 0, 0); } void loop() { Serial.print("Time:"); //Serial.print(rtc.formatTime(RTCC_TIME_HM)); Serial.print(rtc.formatTime()); Serial.print("\t Date:"); //Serial.println(rtc.formatDate(RTCC_DATE_ASIA)); Serial.println(rtc.formatDate()); delay(1000); }

In this code, at first, time information including the day, month, century and year and then hours, minutes and seconds are set as the starting point. Module starts working and is updated every second. Then every second the data is received from module and displayed in the Serial Monitor.

The output is as follows.

Liked What You See?​
Get Updates And Learn From The Best​

Comments (3)

  • lockie cresswell Reply

    Hi,
    a couple of days ago I got three new Pcf8563 based RTC modules for my Arduino projects. I am using the library and code you suggested and I am trying to set the clock. Unfortunately I can read the clock but not set it. No matter what I try the serial monitor always outputs:

    45:85:85
    25/45/19@5

    i have now tried four modules and they all do the same, regardless of what micro I use. I have tried previously 6 months ago with success using a STM32, except for one module which gave the above readout. At the time I thought it was faulty and just ignored it , but now I have three new modules all doing the same. Someone else has commented in 2018 on a Arduino forum that they also has identical problem, so I wondered what you might think. It may be that they are faulty since my first three work well using the same code.

    February 3, 2023 at 1:05 pm
    • Ali Abdolmaleki Reply

      Hi dear
      are you sure about I2C connection?
      first aval please check the connection with I2C scanner library, you shoulde receive Sensor ID with this library

      February 28, 2023 at 2:02 pm
  • Clive Private Reply

    Please ensure that you are using A4 & A5 not D4 & D5 as I did with the same result as you have (easy mistake to make).

    February 11, 2024 at 5:07 pm

Leave a Reply

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