The other example, datecalc, does seem to run, however.
I'm on a Windows Vista machine, and other sketches run on the Uno.
With Uno disconnected, I removed the battery, waited while I measured its voltage, and reinserted the battery.
The battery voltage is 3.36, inserted with + on top.
I used the example ds1307 sketch from the Adafruit Learning System "Understanding the Code" page to try to set the time,
http://learn.adafruit.com/ds1307-real-t ... g-the-code ,
and modified it to remove the
"if (! RTC.isrunning()) {" section, and added some debug serial print statements to it.
Before the added debug prints, nothing was printed on the serial monitor at all.
With debug prints before and after the
"rtc.adjust(DateTime(__DATE__, __TIME__));",
the debug text BEFORE the adjust time is printed, but the debug text
AFTER adjust time is NOT printed, nor is any debug text INSIDE the main loop printed, nor are the originally intended prints inside the loop printed, either.
With the ADJUST TIME commented out, the debug text both before and after the adjust time statement prints, as does the FIRST debug text INSIDE the main loop, BUT no further printing from inside the loop occurs.
On the other hand, the results of running the DATECALC example are these:
dt0 2000/1/1 0:0:0 = 946684800s / 10957d since 1970
dt1 2001/1/1 0:0:0 = 978307200s / 11323d since 1970
dt2 2009/1/1 0:0:0 = 1230768000s / 14245d since 1970
dt3 2009/1/2 0:0:0 = 1230854400s / 14246d since 1970
dt4 2009/1/27 0:0:0 = 1233014400s / 14271d since 1970
dt5 2009/2/27 0:0:0 = 1235692800s / 14302d since 1970
dt6 2009/12/27 0:0:0 = 1261872000s / 14605d since 1970
dt7 2009/12/27 1:0:0 = 1261875600s / 14605d since 1970
dt8 2009/12/28 0:0:0 = 1261958400s / 14606d since 1970
dt9 2010/1/3 0:0:0 = 1262476800s / 14612d since 1970
The modified ds1307 example code is this:
(I tried to use the "copy for forum" tool, but a bunch of errors not previously seen under compile nor upload occurred.)
Code: Select all
// 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);
#ifdef AVR
Wire.begin();
#else
Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
rtc.begin();
Serial.println("setting the time/date?");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(__DATE__, __TIME__));
Serial.println("finished setting the time/date?");
}
void loop () {
Serial.println("in beginning of loop");
DateTime now = rtc.now();
Serial.println("just after DateTime 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(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.print(" since midnight 1/1/1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");
// calculate a date which is 7 days and 30 seconds into the future
DateTime future (now.unixtime() + 7 * 86400L + 30);
Serial.print(" now + 7d + 30s: ");
Serial.print(future.year(), DEC);
Serial.print('/');
Serial.print(future.month(), DEC);
Serial.print('/');
Serial.print(future.day(), DEC);
Serial.print(' ');
Serial.print(future.hour(), DEC);
Serial.print(':');
Serial.print(future.minute(), DEC);
Serial.print(':');
Serial.print(future.second(), DEC);
Serial.println();
Serial.println();
delay(3000);
}