Hello all.
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 Arduino Playground - UsbMemory, relevant bit is near the bottom of the page):
#include <Wire.h>
int second = 0;
int minute = 0;
int hour =0;
int day_of_week=0;
int day = 0;
int month = 0;
int year = 0;
void setup()
{
Wire.begin();
Serial.begin(9600);
delay(100);
}
void loop()
{
// reset register pointer
Wire.beginTransmission(0x68);
Wire.send(0);
Wire.endTransmission();
// request 7 bytes from ds1307
Wire.requestFrom(104, 7);
second = Wire.receive();
minute = Wire.receive();
hour = Wire.receive();
day_of_week=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(":");
Serial.print( minutes );
Serial.println();
//no need to rush
delay(1000);
}
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.