Real Time Clock(RTC)

Working principle

An RTC or Real Time Clock is a Timekeeping device, usually in the form of an Integrated Circuit (IC). An RTC is battery powered and keeps track of the current time even when there is no power.Real Time Clock ICs are present in computers, servers, many embedded systems and in fact they are used wherever it is required to keep an accurate time. 

 

Description:

realtime clock (RTC) is a computer clock (most often in the form of an integrated circuit) that keeps track of the current time. Although the term often refers to the devices in personal computers, servers and embedded systems, RTCs are present in almost any electronic device which needs to keep accurate time.

 

 

Features:

  • Real-time clock (RTC) counts seconds,minutes, hours, date of the month, month, daof the week, and year with leap-year compensation valid up to 2100
  • 56-byte, battery-backed, nonvolatile (NV) RAM for data storage
  • Two-wire serial interface
  • Programmable squarewave output signal
  • Automatic power-fail detect and switch circuitry
  • Consumes less than 500nA in battery backup mode with oscillator running
  • Optional industrial temperature range:-40°C to +85°C
  • Available in 8-pin DIP or SOIC Underwriters Laboratory (UL) recognized

 

Specifications:

 

  • Two-wire I2C interface.
  • Hour: Minutes: Seconds AM/PM.
  • Day Month, Date – Year.
  • DS1307 based RTC (Battery include).
  • 1Hz output pin.
  • Available in 8-pin DIP or SOIC

 

Link to Datasheet:

https://datasheets.maximintegrated.com/en/ds/DS1307.pdf

 

Do’s and Don’ts:

How do you plan to use the Real-Time Clock/Calendar in your application or design? Here are some examples of how RTCC Technology can take your applications to bigger and better places.

  • Smart Energy
    Smart Energy applications can use a real-time clock with a MAC address for wired and wireless communications with other devices.   
  • Utility Metering
    Digital trimming in the real-time clock can be used to perform software temperature compensation for more accurate time.   
  • Ethernet
    The EUI-48™ or EUI-64™ MAC Address in the RTCC can provide any Ethernet enabled application with its own unique identification.   
  • LCD
    The time of day and date from a real-time clock is regularly displayed on the LCD in many systems.

 

Advantages:

Following are the advantages of motion sensor of active and passive types.

  • Error is almost negligible.
  • Efficiency of
  • Program complexity.
  • Memory space usage is low.
  • CPU usage is low.

Disadvantages 

motion sensor of active and passive types:

  • Ease of interfacing is high.
  • Cost is high compare to internal timers.

                                       Schamatic:

Connection With Arduino:

 

  • VCC :  To  be connected to 5v supply
  • SDA: To be connected to A4 Pin of arduino
  • SCL: To be connected to A5 pin of arduino
  • GND : To be  connected to ground 

 

Arduino Code:

/*

  DS1307 RTC (Real-Time-Clock) Example 

  Uno       A4 (SDA), A5 (SCL)

  Mega      20 (SDA), 21 (SCL)

  Leonardo   2 (SDA),  3 (SCL)

 */

#include <Wire.h>

#include <DS1307.h>

DS1307 rtc;

void setup()

{

  /*init Serial port*/

  Serial.begin(9600);

  while(!Serial); /*wait for serial port to connect – needed for Leonardo only*/

  /*init RTC*/

  Serial.println(“Init RTC…”);

  /*only set the date+time one time*/

  rtc.set(0, 0, 8, 24, 12, 2014); /*08:00:00 24.12.2014 //sec, min, hour, day, month, year*/

  /*stop/pause RTC*/

  // rtc.stop();

  /*start RTC*/

  rtc.start();

}

void loop()

{

  uint8_t sec, min, hour, day, month;

  uint16_t year;

  /*get time from RTC*/

  rtc.get(&sec, &min, &hour, &day, &month, &year);

  /*serial output*/

  Serial.print(“\nTime: “);

  Serial.print(hour, DEC);

  Serial.print(“:”);

  Serial.print(min, DEC);

  Serial.print(“:”);

  Serial.print(sec, DEC);

  Serial.print(“\nDate: “);

  Serial.print(day, DEC);

  Serial.print(“.”);

  Serial.print(month, DEC);

  Serial.print(“.”);

  Serial.print(year, DEC);

  /*wait a second*/

  delay(1000);

}

Reference:

https://www.electronicshub.org/arduino-real-time-clock-tutorial/

https://www.engineersgarage.com/real-time-clock

https://www.microchip.com/design-centers/real-time-clock-calendar/applications