I know there are a few threads about this component, but I'm having some weirdness that I haven't seen mentioned elsewhere.
I'm using the Sparkfun Real Time Clock Module with an older (pre-NG) Arduino.
With Wire.h, I'm able to communicate with the clock, set the time and read it, but after a few hours, the clock seems to go all crackers on me.
Typically what I have observed is this : after running well for a few hours, at the change of a new hour (has happened at 12h, 14h, and 6h), the clock will jump to 2h, for no apparent reason.
I'm using code I found in the playground ( at http://www.arduino.cc/playground/Main/UsbMemory
, relevant bit is near the bottom of the page):
int second = 0;
int minute = 0;
int hour =0;
int day = 0;
int month = 0;
int year = 0;
// reset register pointer
// request 7 bytes from ds1307
second = Wire.receive();
minute = Wire.receive();
hour = Wire.receive();
day = Wire.receive();
month = Wire.receive();
year = Wire.receive();
// Convert all the BCD values that might have "tens" to decimal
int hours=hour/16* 10 + hour % 16;
int minutes=minute/16 * 10 + minute % 16;
int days=day/16 * 10 + day % 16;
int months=month/16 * 10 + month % 16;
Serial.print( hour );
Serial.print( minutes );
//no need to rush
I'm using pull-up resistors in there, the circuit is built as it ought be, yet the clock (actually 2 different ones) consistently gives me this problem.
Any ideas what is going on? Is it a code issue? A problem with using this older board? An issue with the clock modules (somehow I think that is unlikely)?
I have posted a similar topic at sparkfun in case it's a clock issue, but i have a feeling it's either in my code, or because of the older board. I'll be testing out an NG this afternoon (no fancy Decimilia for me yet!), but curious if anyone has any insight into this.