Arduino Real Time Clock modules RTC DS1307

$13.80
  • Units in Stock: 15
  • Date Added: Tuesday 27 July, 2010
Add to Cart:

Product Description:

Real-time clock can provide the date and time information to the electronic circuit, including year, month, day, hour, minute, second. It is widely used in occasions while timing is needed. Many real-time clock circuits are also battery-powered, so that in case of power-down, the time datais still accurate. Generally speaking, real-time clock with more function will provide additional features including alarm, watchdog, and supporting calibration registers.

DS1307 is a kind of realtime chip produced by DALLAS company. It communicateswith MCU by I2C protocol. So it is very convenient to connect this to I2C interface of Arduino. DS1307 has a programmable waveform output inteface, which can be used to drive LED light, or as interrupt to trigger certain events. However,Please pay more attention while using it to drive high-power module. We have designed a real-time clock module. We extend the I2C interface and a programmable waveform output interface SQW for easy connectiong. However, usually we will only I2C interface to set or read from the module.

Note that the module must be installed with the battery. It uses a button cell battery (model CR1220), positive upward:

We can use the Arduino special sensor board V4. Connect wires on the IIC's position:

Then use 4-core I2C/COM cable to connect the special interface of board to IIC (I2C is actually short for IIC) of real-time clock module:

Hardware connection is completed. Then comes programming. I'm using the DS1307 library on the Google Code repository. Click here to download. Extract the zip file to /libraries directory of Arduino 0018, restart the Arduino and use the testing procedures for testing:

#include
#include
#include // written by mattt on the Arduino forum and modified by D. Sjunnesson
void setup()
{
Serial.begin(9600);
RTC.stop();
RTC.set(DS1307_SEC,1); //set the seconds
RTC.set(DS1307_MIN,23); //set the minutes
RTC.set(DS1307_HR,12); //set the hours
RTC.set(DS1307_DOW,4); //set the day of the week
RTC.set(DS1307_DATE,15); //set the date
RTC.set(DS1307_MTH,7); //set the month
RTC.set(DS1307_YR,10); //set the year
RTC.start();
}
void loop()
{
Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
Serial.print(":");
Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
Serial.print(":");
Serial.print(RTC.get(DS1307_SEC,false));//read seconds
Serial.print(" "); // some space for a more happy life
Serial.print(RTC.get(DS1307_DATE,false));//read date
Serial.print("/");
Serial.print(RTC.get(DS1307_MTH,false));//read month
Serial.print("/");
Serial.print(RTC.get(DS1307_YR,false)); //read year
Serial.println();
delay(1000);
}

It is not hard to understand the code. Basically it uses RTC.set to set the clock, then use RTC.get to read time information. As to how to maintain clock accuracy, that is DS1307's work:)

Download the program to the Arduino and run it, you can view the serial output:

Qty Discounts Off Price
1-4
$13.80
5-9
$11.73
10-49
$11.32
50+
$9.66
Copyright © 2013 Elechouse.
Powered by ELECHOUSE