Introduction
A real-time clock (RTC) is a computer clock (most often in the form of an integrated circuit) that keeps track of the current time. The term real-time clock is used to avoid confusion with ordinary hardware clocks which are only signals that govern digital electronics and do not count time in human units. (Wikipedia)
evive has an inbuilt RTC IC, PCF8563. The IC gets power from the internal battery of evive so it can continue to keep time while the external source of power is off or unavailable.
PCF8563
The PCF8563 is a CMOS Real-Time Clock and calendar optimized for low power consumption. A programmable clock output, interrupt output, and a low voltage detector is also provided. All addresses and data are transferred serially via a two-line bidirectional IIC-bus. Maximum bus speed is 400 kbit/s. The registered address is incremented automatically after each written or read data byte.
It provides the year, month, day, weekday, hours, minutes, and seconds based on a 32.768 kHz quartz crystal. It also has a century flag, alarm and timer functions, integrated oscillator capacitor and internal Power-On Reset.
Read/Write on RTC in Arduino IDE
evive communicates with RTC via IIC-bus using wire.h library. Any data that comes in or comes out of RTC is in Binary-Coded Decimal (BCD) of eight bits.
Example
Given below is sample code demonstrating how to read and write on RTC.
RTC on PictoBlox (Scatch)
In evive extension, there are blocks for the following purposes:
You can use these block in Stage Mode and Upload Mode.
Example
Here are some example scripts showing how to use the above blocks:
- In this program, we set the time on the clock to the present time and then we display it on evive’s TFT.
- In this program, we set the date on the clock to the present date and then we display it on evive’s TFT.