I have a 1307 rtc and i am having a few issues with it.
EDIT:
I wrote a simple sketch like this:
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
void setup () {
Serial.begin(57600);
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
//RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop () {
DateTime now = RTC.now();
Serial.println(now.minute(), DEC);
}
The output on serial is like this:
12
12
12
12
165
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
0
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
165
As you can see, it is mostly correct, but often wrong. This is a problem because I am displaying the time on a LCD screen, and the fact that the numbers are changing is causing the lcd screen to shimmer. (if i remove the code to display the time, the shimmer is gone)
/////
original post below
I have set up the module so that the time is displayed on a character LCD. The time display correctly, however, i noticed there was a little "shimmer" on the display, on the line that displays the time.
I had though this was because that line was being over wrote, so i decided to write some code so that the screen would only be updated if the minutes had changed...
if(AoldMinute != minute || zoneSetup > 0){
//Serial.println(zoneSetup);
// Serial.println(AoldMinute);
Serial.println("start");
Serial.println(minute);
Serial.println("end");
AoldMinute = minute;
//Serial.println(AoldMinute);
refresh = 1;
}
However, the problem with this is that when i print out minute, it changes frequently.
Here is the example serial output:
start
165
end
start
50
end
start
0
end
start
51
end
start
23
end
start
51
end
start
0
end
start
51
end
start
165
end
start
51
end
start
0
Interestingy, 23:51 is the time
here is where i get the minute from the rtc:
void loop()
{
now = clock.now();
month = now.month();
day = now.day();
dayName = now.dayOfWeek();
year = now.year();
hour = now.hour();
timerHandler();
if (hour > 12) {
hour = hour - 12;
PMflag = 1;
} else PMflag = 0;
if (hour == 0) {
hour = 12;
}
minute = now.minute();
second = now.second();
...
}
I have included my full code below.
RFledBoxTs.zip (14.1 KB)