I am building a Clock/calender using Arduino Uno and the DS1302 RTC. In testing the RTC prior to installing it with Sketch code intended to drive the Clock and display, the time I have found that with a simple Sketch with only a few lines of code to set the Clock Time & date etc then continuously read back the the time and date and display them, everything is fine and stable. If I then set up the Sketch code that I intend to use for the clock the readings from the RTC are erratic. I can get stable results for about 3 minutes then unassociated values for about 3 minutes. These two types of events occur with regularity. Has anyone any experience of using this RTC and found similar results and hopefully found the cause and a cure.?
please post the code that shows this effect...
Hi Rob - Here is the piece of code which does the reading of the RTC and displaying the results. Hope you can spot something which may help. :-
curTime = rtc.getTimeStr(FORMAT_SHORT);
curHour = curTime.substring(0,2);
curMin = curTime.substring(3,5);
tDig = curHour.toInt();
mdHour =tDig;
sHour1 = tDig/10;
sHour2 = tDig % 10;
tDig = curMin.toInt();
sMin1 = tDig/10;
sMin2 = tDig % 10;
matrix.writeDigitNum(0,sHour1);
matrix.writeDigitNum(1,sHour2);
//matrix.writeDisplay();
matrix.writeDigitNum(3,sMin1);
matrix.writeDigitNum(4,sMin2);
matrix.drawColon(true);
matrix.writeDisplay();
zpos = 0;
// wait 6 seconds before reading time again
while(zpos <6) {
matrix.drawColon(colDots);
// matrix.writeDisplay();
colDots = !colDots; // Flash colons on 7- Seg display
delay(500); // evert second.
matrix.drawColon(colDots);
// matrix.writeDisplay();
colDots = !colDots;
delay(500);
zpos++; }
}
see no error in the code part ![]()
but I cannot compile it either as it is not a complete sketch ![]()
I expect you are using the String class which is famous in negative sense for creating a Swiss cheese from your limited SRAM.