Arduino Library for Chronodot
Moderators: adafruit_support_bill, adafruit

Arduino Library for Chronodot

by stephanie on Sun Apr 10, 2011 10:26 am

I know the Chronodot can be used as-is with the DS1307 library but the chronodot can also provide temperature data via the i2c in addition to the time, and I wanted to access the temperature data in a sketch I was working on.

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 | TOGGLE FULL SIZE
// 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);
}
User avatar
stephanie
 
Posts: 295
Joined: Sat Dec 11, 2010 12:17 am
Location: Canada

Re: Arduino Library for Chronodot

by adafruit_support_bill on Mon Apr 11, 2011 5:05 am

Thanks, Stephanie! I'm sure many will find this useful. :D
User avatar
adafruit_support_bill
 
Posts: 29057
Joined: Sat Feb 07, 2009 9:11 am