Features
- Low Power Consumption: Optimized for minimal power use, suitable for battery-operated devices.
- Accurate Timekeeping: Provides year, month, day, weekday, hours, minutes, and seconds.
- I²C Communication: Uses a two-line bidirectional I²C bus for data transfer, max speed 400 kbit/s.
- Programmable Outputs: Includes a programmable clock output and interrupt output.
- Voltage-Low Detector: Monitors voltage levels to ensure reliable operation.
- Compact Design: Integrated oscillator capacitor and internal Power-On Reset (POR).
Specifications
- Battery Model: CR1220 3V (Not Included)
- Clock Operating Voltage: 1.0 V to 5.5 V at room temperature
- Backup Current: Typical 0.25 µA at VDD = 3.0 V and Tamb = 25°C
- I²C Bus Interface: 400 kHz two-wire interface (at VDD = 1.8 V to 5.5 V)
- Programmable Clock Output: 32.768 kHz, 1.024 kHz, 32 Hz, and 1 Hz
- Alarm and Timer Functions: Built-in for versatile applications
- Internal Power-On Reset (POR)
- I²C Bus Slave Address: Read A3h and write A2h
- Interrupt Pin: Open-drain
Resources
Arduino Code for PCF8563 RTC Module (No Library Needed)
#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() {
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() {
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);
hour = bcdToDec(Wire.read() & B00111111);
dayOfMonth = bcdToDec(Wire.read() & B00111111);
dayOfWeek = bcdToDec(Wire.read() & B00000111);
month = bcdToDec(Wire.read() & B00011111); // remove century bit
year = bcdToDec(Wire.read());
}
void setup() {
Wire.begin();
Serial.begin(9600);
// Set initial time here (change as needed)
second = 0;
minute = 28;
hour = 9;
dayOfWeek = 2;
dayOfMonth = 13;
month = 8;
year = 13; // year 2013
// Comment the next line after setting the time once
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);
}
Features
- Low Power Consumption: Optimized for minimal power use, suitable for battery-operated devices.
- Accurate Timekeeping: Provides year, month, day, weekday, hours, minutes, and seconds.
- I²C Communication: Uses a two-line bidirectional I²C bus for data transfer, max speed 400 kbit/s.
- Programmable Outputs: Includes a programmable clock output and interrupt output.
- Voltage-Low Detector: Monitors voltage levels to ensure reliable operation.
- Compact Design: Integrated oscillator capacitor and internal Power-On Reset (POR).
Specifications
- Battery Model: CR1220 3V (Not Included)
- Clock Operating Voltage: 1.0 V to 5.5 V at room temperature
- Backup Current: Typical 0.25 µA at VDD = 3.0 V and Tamb = 25°C
- I²C Bus Interface: 400 kHz two-wire interface (at VDD = 1.8 V to 5.5 V)
- Programmable Clock Output: 32.768 kHz, 1.024 kHz, 32 Hz, and 1 Hz
- Alarm and Timer Functions: Built-in for versatile applications
- Internal Power-On Reset (POR)
- I²C Bus Slave Address: Read A3h and write A2h
- Interrupt Pin: Open-drain
Resources
Arduino Code for PCF8563 RTC Module (No Library Needed)
#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() {
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() {
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);
hour = bcdToDec(Wire.read() & B00111111);
dayOfMonth = bcdToDec(Wire.read() & B00111111);
dayOfWeek = bcdToDec(Wire.read() & B00000111);
month = bcdToDec(Wire.read() & B00011111); // remove century bit
year = bcdToDec(Wire.read());
}
void setup() {
Wire.begin();
Serial.begin(9600);
// Set initial time here (change as needed)
second = 0;
minute = 28;
hour = 9;
dayOfWeek = 2;
dayOfMonth = 13;
month = 8;
year = 13; // year 2013
// Comment the next line after setting the time once
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);
}