bigone5500:
It's all good brother! I'm having mental overload with all these suggestions really. My last change to the sketch ended up all fouled up. at 12PM, it said it was -2:00...what???
I am using the last code suggested to see if things work out well.
Exactly - you are checking if the clock is after 10 instead of 12
Give it a try with the code I suggested you'll see it's easy to read and no String needed
void printTime(int character, int line, tmElements_t &tm)
{
lcd.setCursor(character, line);
if (tm.Hour > 12) {
if (tm.Hour < 22) lcd.print(F("0"));
lcd.print(tm.Hour - 12);
} else {
if (tm.Hour < 10) lcd.print(F("0"));
lcd.print(tm.Hour);
}
lcd.print(":");
if (tm.Minute < 10) lcd.print(F("0"));
lcd.print(tm.Minute);
lcd.print(":");
if (tm.Second < 10) lcd.print(F("0"));
lcd.print(tm.Second);
if (tm.Hour >= 12) lcd.print(F(" PM "));
else lcd.print(F(" AM "));
}
This is the last code I tried. I looked at the clock this morning and it seems that did the trick. I will print this sketch on paper and study it. I see why my other attempt ended up with a negative time.
I'd like to figure out what the 'F' in the lcd.print means. But don't tell me, I'll study the code and do some research and see if I can figure it out.
bigone5500:
I'd like to figure out what the 'F' in the lcd.print means. But don't tell me, I'll study the code and do some research and see if I can figure it out.
Since getting this code to work correctly, the clock is now 13 minutes fast. Is this due to code or the hardware itself? Is there something I can do besides constantly reset the RTC?
bigone5500:
Since getting this code to work correctly, the clock is now 13 minutes fast. Is this due to code or the hardware itself? Is there something I can do besides constantly reset the RTC?
Yes That's because you use a DS1307 as your RTC. those components are very poor to keep time accurate. go for a DS3231 and they will be better for much longer period
J-M-L:
Yes That's because you use a DS1307 as your RTC. those components are very poor to keep time accurate. go for a DS3231 and they will be better for much longer period
Are you sure that the DS1307 is the problem, and not whatever library the OP is using?
Note sure about the library but the 1307 is notoriously loosing sync quickly as it is not Temperature compensated (external temperature can affect the frequency of the oscillator circuit which drives the DS1307’s internal counter - clock will be off by around five or more minutes per month)