DS1302 module doesn't work properly

Hi everyone, I'm trying to use a DS1302 module for arduino like this one:

The problem is that time doesn't advance correctly (time increases of 1 second every 10-20 seconds).
I'm using this library: DS1302 - Rinky-Dink Electronics

#include <DS1302.h>

// Init the DS1302
DS1302 rtc(5, 7, 6);

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

}

void loop()
{
  // Send Day-of-Week
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");
  
  // Send date
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");

  // Send time
  Serial.println(rtc.getTimeStr());
  
  // Wait one second before repeating :)
  delay (1000);
}

Anyone can help me?

Get rid of the delay!

That DS1302 is a stand alone device which should be ticking away completely independently of the delay() in your code. I don't think the delay has anything to do with it. Is there any chance you left the reset pin on the DS1302 floating? All pins, even those not used, should generally be tied high or low. If not, just try using different digital pins for the interface. I don't know why that would matter, but as Sherlock Holmes once said, when you run out of logical possibilities, you start looking at the illogical possibilities.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.