Task 3: Implement Real Time Clock Storage and Retrieval

Once you’ve synced time over Wi-Fi, that time needs to be stored and retrieved from the PCF8563 real-time clock so it persists and can be read even without a network connection.

This task must be implemented in pure C — no C++ classes for this module.

Implementation Guidance

– See this reference for PCF8563 basics: Tutorial – Arduino and PCF8563 Real Time Clock IC
– Use bcdToDec() and decToBcd() helper functions, since the PCF8563 stores time values in BCD (binary-coded decimal) format, not plain binary
– Note: the PCF8563’s I2C address is sometimes incorrectly listed in online resources — verify the correct address against the actual datasheet
– Study the datasheet carefully for register addresses, bit masking requirements, and valid value ranges for each time field
– Use snprintf() to format time values into readable strings for display
– See this reference for the timeinfo struct: cplusplus.com – struct tm
– Note that struct tm’s month field is zero-indexed (0-11) and its year field is years since 1900, so both require translation when converting to/from human-readable format

[img: Module 2 Task 3 Picture 1]
[img: Module 2 Task 3 Picture 2]

Recommended File Structure

mytime.h / mytime.c — PCF8563 RTC read/write functions (C only)
mywifi.h / mywifi.cpp — Wi-Fi connection and NTP sync
display.h / display.cpp — display functions
power.h / power.cpp — power management
main.cpp — ties everything together