Grove - RTC

From Wiki
Jump to: navigation, search

Contents

Introduction

The RTC module is based on the clock chip DS1307 which supports the I2C protocol. It utilizes a Lithium cell battery (CR1225). The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with AM/PM indicator.

Note: Battery is not included.

Model:SEN12671P

RTC.jpg

Features

  • Real-Time Clock (RTC) Counts Seconds,Minutes, Hours, Date of the Month, Month,Day of the week, and Year with Leap-Year Compensatio
  • Valid Up to 2100
  • 56-Byte, Battery-Backed, Nonvolatile (NV)RAM for Data Storage
  • I2C Serial Interface
  • 5V DC supply
  • Programmable Square-Wave Output Signal
  • Automatic Power-Fail Detect and Switch Circuitry
  • Low power consumption

Application Ideas

  • Calendar
  • Intelligent instrument
  • Industrial control

Caution

In order to gain a robust performance, you must put a 3-Volt CR1225 lithium cell in the battery-holder. If you use the primary power only, the module may not work normally, because the crystal may not oscillate.

Specification

Key Specification

Items Min
PCB Size 2.0cm*4.0cm
Interface 2.0mm pitch pin header
IO Structure SCL,SDA,VCC,GND
ROHS YES

Electronic Characterstics

Items Min Norm Max Unit
VCC 4.5 5.0 5.5 V
Logic High Level Input 2.2 - VCC+0.3 V
Logic Low Level Input -0.3 - +0.8 V
VBAT (Battery Voltage) 2.0 3.0 3.5 V
VBAT Current (OSC ON),SQW/OUT OFF - 300 500 nA
(OSC ON),
SQW/OUT ON (32kHz)
- 480 800 nA
Data-Retention Current
(Oscillator Off)
- 10 100 nA

Usage

The following sketch demonstrates a simple application of setting the time and reading it out.

  • Connect the module to the I2C Interface of Grove- Base Shield.
  • Plug Grove- Base Shield into Arduino.
  • Connect Arduino to PC via a USB cable.
  • Download the library File:RTC Library
  • Unzip it into the libraries file of Arduino IDE by the path: ..\arduino-1.0\libraries.
  • Open the code directly by the path:File -> Example ->RTC->SetTimeAndDisplay.
 
#include <Wire.h>
#include "DS1307.h"

DS1307 clock;//define a object of DS1307 class
void setup()
{
	Serial.begin(9600);
	clock.begin();
	clock.fillByYMD(2013,1,19);//Jan 19,2013
	clock.fillByHMS(15,28,30);//15:28 30"
	clock.fillDayOfWeek(SAT);//Saturday
	clock.setTime();//write time to the RTC chip
}
void loop()
{
	printTime();
}
/*Function: Display time on the serial monitor*/
void printTime()
{
	clock.getTime();
	Serial.print(clock.hour, DEC);
	Serial.print(":");
	Serial.print(clock.minute, DEC);
	Serial.print(":");
	Serial.print(clock.second, DEC);
	Serial.print("	");
	Serial.print(clock.month, DEC);
	Serial.print("/");
	Serial.print(clock.dayOfMonth, DEC);
	Serial.print("/");
	Serial.print(clock.year+2000, DEC);
	Serial.print(" ");
	Serial.print(clock.dayOfMonth);
	Serial.print("*");
	switch (clock.dayOfWeek)// Friendly printout the weekday
	{
		case MON:
		  Serial.print("MON");
		  break;
		case TUE:
		  Serial.print("TUE");
		  break;
		case WED:
		  Serial.print("WED");
		  break;
		case THU:
		  Serial.print("THU");
		  break;
		case FRI:
		  Serial.print("FRI");
		  break;
		case SAT:
		  Serial.print("SAT");
		  break;
		case SUN:
		  Serial.print("SUN");
		  break;
	}
	Serial.println(" ");
}
  • Set the time. Put function arguments change to current date/time. The attention should be paid to the arguments format.
        clock.fillByYMD(2013,1,19);//Jan 19,2013
	clock.fillByHMS(15,28,30);//15:28 30"
	clock.fillDayOfWeek(SAT);//Saturday
  • Upload the code. Please click here if you do not know how to upload.
  • Open the serial monitor to see the result.
 
RTC result.jpg

The output time is changing like the clock.

Version Tracker

Revision Descriptions Release
v0.9b Initial public release Jan 14, 2011

Resources

Support

If you have questions or other better design ideas, you can go to our forum or wish to discuss.

Personal tools
Namespaces

Variants
Actions
Structure
Seeed Products
Support
Toolbox