I'm having an interesting little problem integrating a chronodot into a project I have, and I'm now looking for a little assistance. I have the time and date set correctly, and when I run the DS1307 example sketch, everything prints out nicely and works just fine. I then added some modified code into my existing project to print the unix time at the end of each line of a csv logfile it creates. However, the unix time it logs only updates every 128 seconds, so it prints the same value 128 times (the project logs data once per second) and then switches to a value 128 seconds higher and so on.
Then, to troubleshoot, I ran the RTC code I wrote on its own, using everything hooked up identically, and printed it to the serial instead of a logfile, and it only updates every 64 seconds.... I'm stumped. Here is the code I ran on its own.
Code: Select all
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
float time;
void setup () {
Serial.begin(57600);
Wire.begin();
RTC.begin();
}
void gettime(void){
DateTime now = RTC.now();
time = now.unixtime();
}
void loop () {
gettime();
Serial.println(time);
delay(1000);
}
Any help would be appreciated.
Thanks,
Thomas