Electronics

Real Time Clock RTC Module PCF8563T

AED 12.60

1

Description

The PCF8563 is a CMOS Real-Time Clock (RTC) and calendar optimized for low power consumption. A programmable clock output, interrupt output, and a voltage-low detector is also provided. All addresses and data are transferred serially via a two-line bidirectional I²C-bus. The maximum bus speed is 400 kbit/s it has to be Powerd with a CR1220 Coin battery.

 

Specifications:

The battery Model is CR1220 3V (Not Included)

Provides year, month, day, weekday, hours, minutes, and seconds based on a
32.768 kHz quartz crystal
Century flag
Clock operating voltage: 1.0 V to 5.5 V at room temperature
Low backup current; typical 0.25 uA at VDD = 3.0 V and Tamb = 25 C
400 kHz two-wire I2C-bus interface (at VDD = 1.8 V to 5.5 V)
Programmable clock output for peripheral devices (32.768 kHz, 1.024 kHz, 32 Hz, and 1 Hz)
Alarm and timer functions
Integrated oscillator capacitor
Internal Power-On Reset (POR)
2C-bus slave address: read A3h and write A2h
Open-drain interrupt pin


For More information on the PCF8531 RTC, you can read the Datasheet by clicking Here


Arduino Code for PCF8563 RTC module (No Need For Library):

#include "Wire.h"

#define PCF8563address 0x51

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
String days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };

byte bcdToDec(byte value)
{
return ((value / 16) * 10 + value % 16);
}

byte decToBcd(byte value){
return (value / 10 * 16 + value % 10);
}

void setPCF8563()
// this sets the time and date to the PCF8563
{
Wire.beginTransmission(PCF8563address);
Wire.write(0x02);
Wire.write(decToBcd(second)); 
Wire.write(decToBcd(minute));
Wire.write(decToBcd(hour)); 
Wire.write(decToBcd(dayOfMonth));
Wire.write(decToBcd(dayOfWeek)); 
Wire.write(decToBcd(month));
Wire.write(decToBcd(year));
Wire.endTransmission();
}

void readPCF8563()
// this gets the time and date from the PCF8563
{
Wire.beginTransmission(PCF8563address);
Wire.write(0x02);
Wire.endTransmission();
Wire.requestFrom(PCF8563address, 7);
second = bcdToDec(Wire.read() & B01111111); // remove VL error bit
minute = bcdToDec(Wire.read() & B01111111); // remove unwanted bits from MSB
hour = bcdToDec(Wire.read() & B00111111); 
dayOfMonth = bcdToDec(Wire.read() & B00111111);
dayOfWeek = bcdToDec(Wire.read() & B00000111); 
month = bcdToDec(Wire.read() & B00011111); // remove century bit, 1999 is over
year = bcdToDec(Wire.read());
}

void setup()
{
Wire.begin();
Serial.begin(9600);
// change the following to set your initial time
second = 0;
minute = 28;
hour = 9;
dayOfWeek = 2;
dayOfMonth = 13;
month = 8;
year = 13;
// comment out the next line and upload again to set and keep the time from resetting every reset
setPCF8563();
}

void loop()
{
readPCF8563();
Serial.print(days[dayOfWeek]); 
Serial.print(" "); 
Serial.print(dayOfMonth, DEC);
Serial.print("/");
Serial.print(month, DEC);
Serial.print("/20");
Serial.print(year, DEC);
Serial.print(" - ");
Serial.print(hour, DEC);
Serial.print(":");
if (minute < 10)
{
Serial.print("0");
}
Serial.print(minute, DEC);
Serial.print(":"); 
if (second < 10)
{
Serial.print("0");

Serial.println(second, DEC); 
delay(1000);
}