Datasheet

and then later we'll show how to modify the shield!
For the RTC library, we'll be using a fork of JeeLab's excellent RTC library. Please download it
now. (http://adafru.it/cfG) Then install it in your Arduino directory (http://adafru.it/aYM) in a
folder called RTClib
First RTC test
The first thing we'll demonstrate is a test sketch that will read the time from the RTC once a
second. We'll also show what happens if you remove the battery and replace it since that
causes the RTC to halt. So to start, remove the battery from the holder while the Arduino is
not powered or plugged into USB. Wait 3 seconds and then replace the battery. This resets
the RTC chip. Now load up the following sketch (which is also found in Examples->RTClib-
>ds1307) and upload it to your Arduino with the datalogger shield on!
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
void setup () {
Serial.begin(57600);
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
// uncomment it & upload to set the time, date and start run the RTC!
//RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop () {
DateTime now = RTC.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
© Adafruit Industries https://learn.adafruit.com/adafruit-data-logger-shield Page 17 of 68