How to use evive's Real-time Clock

About This Tutorial
This tutorial discusses what is a real-time clock, and how to use evive's real-time clock to show time, date, and day with the help of an Arduino IDE sketch.
Tutorial Info
Programming Platform:
Difficulty:
Estimated Time (hrs):
2

Components Required

ImageComponentQuantityAvailable in Kit
evive1
USB A-B Cable1

Introduction

A real-time clock (RTC) is a clock IC that keeps track of current time and date. It is used in making of computer clocks, digital clocks, attendance systems etc. 

evive has an inbuilt RTC IC, PCF8563. The IC gets power from the internal battery of evive, so it can continue to update time while the external source of power is off or unavailable. 

PCF8563

The PCF8563 is a CMOS logic based Real-Time Clock and Calendar optimized for low power consumption. For the RTC available on evive we can set the starting date and time on it. The RTC IC is communicates with evive on I2C protocol(Two Wire Communication) .

It consists of a 32.768 kHz quartz crystal  that provides year, month, day, weekday, hours, minutes, and seconds. It also has a century flag, alarm and timer functions, integrated oscillator capacitor, and internal Power-On Reset.

Read/Write operations on RTC with evive

evive communicates with RTC via IIC-bus. Below is a list of few read write functions used for RTC  present in evive.h library:

FunctionDescription
initclock()Clears all the RTC registers.
setDate(day,weekDay,month,century,year);Used to set date on RTC. Numeric entries corresponding to day, weekDay,month,century,year are to be given.
setTime(h,m,s)Set the current hour,minutes,seconds for setting start time of RTC.
formatDate(byte style)This function returns date in mm/dd/yyyy or dd-mm-yyyy or yyyy-mm-dd format depending upon hex value of style variable written in it.
formatTime(byte style)Gives time in HH:MM or HH:MM:SS format depending on hex value of style variable written in it.
getWeekDay()returns a number depending upon which day of the week it is. For example this function will return 6 for Saturday.

Example

Below is a sample Arduino IDE sketch demonstrating how to write and read time on RTC:

This Helped
This didn't help
Share this Tutorial
Facebook
Twitter
Google+
Pinterest
Reddit
Print
Related Tutorials
Featured Projects

Leave a Reply

Close Menu
×

Cart