So I modified the DS1307 library to add temperature output (in both degrees F and degrees C).
I packaged it back up into its own little Chronodot library and included an example that returns the temperature along with the time.
Hopefully it'll be of use to someone else. Just unzip it and drop it in your arduino/libraries folder.
Cheers!
Chronodot_Library.zip
Example sketch:
Code: Select all
// Date, time and temperature functions using
// a Chronodot RTC connected via I2C and Wire lib
#include <Wire.h>
#include "Chronodot.h"
Chronodot RTC;
void setup () {
Serial.begin(9600);
Serial.println("Initializing Chronodot.");
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
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(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.print(now.tempC(), DEC);
Serial.println(" degrees Celcius");
Serial.print(now.tempF(), DEC);
Serial.println(" degrees Farenheit");
Serial.println();
delay(3000);
}