RTC DS1302 - always two different times/dates

Hey there,

I’m trying to get my RTC DS1302 running.
Shouldn’t be a problem, but:

When i upload the simple sketch:

#include <DS1302.h>

DS1302 rtc(2, 3, 4);

void setup()
{
// Set the clock to run-mode, and disable the write protection
rtc.halt(false);
rtc.writeProtect(false);

Serial.begin(9600);
// The following lines can be commented out to use the values already stored in the DS1302
rtc.setDOW(SUNDAY); // Set Day-of-Week to FRIDAY
rtc.setTime(20, 14, 25); // Set the time to 12:00:00 (24hr format)
rtc.setDate(21, 5, 2018); // Set the date to August 6th, 2010
}

void loop()
{

Serial.println(rtc.getTimeStr());
Serial.println(rtc.getDateStr());

delay (1000);
}

and I check the serial monitor: the output is:

20:14:25
21.05.2018
00:10:13
10.02.2012
20:14:27
21.05.2018
00:10:14
10.02.2012
20:14:29
21.05.2018
00:10:18
10.02.2012
20:14:31
21.05.2018
00:10:19

and so on…

So for some reason, there is another date/time running next to the set time/date…
I can’t get rid of it.
Does anybody know how to help me please?

Thanks in advance

Woody!

Which library are using? There are multiple versions of DS1302.h available.
Did you try any of the example code that came from the library?

What happens if you only go through the loop once? Do you still get the bogus output?

I’m having the same problem…
As far as I can see, you are using the same library (DS1302 - Rinky-Dink Electronics)

I was playing around… and it seems that (un)even seconds are causing the change of date!

I’m trying to find a bug in the code, will keep you posted