DS 1302 RTC problem

can anyone please help me on "ds 1302 rtc", it shows time "(unknown day) 2000-00-00 00:00:01" when uploaded the code "set_clock" I'm using 3V cr2032 battery also.
It doesn't work though I try to meke change to "arduino-ds-1302-master" "set_clock" example.
Is it requires any other change to liberary.
I'm very new to arduino you can say copy paste user, I'm struggling from three days and googling for issue but unable to fix the problem after using many libraries.

Someone help me please... :confused:

Post a link to the library you're using (there are about half a dozen of them for this chip) and post the code you actually use!

I'm using this lib. but have checked other also the result is same...
https://codeload.github.com/msparks/arduino-ds1302/zip/master

this is example code same as in lib. above

// Example sketch for interfacing with the DS1302 timekeeping chip.
//
// Copyright (c) 2009, Matt Sparks
// All rights reserved.
//
// Redirecting to arduino-ds1302
#include <stdio.h>
#include <DS1302.h>

namespace {

// Set the appropriate digital I/O pin connections. These are the pin
// assignments for the Arduino as well for as the DS1302 chip. See the DS1302
// datasheet:
//
// http://datasheets.maximintegrated.com/en/ds/DS1302.pdf
const int kCePin = 5; // Chip Enable
const int kIoPin = 6; // Input/Output
const int kSclkPin = 7; // Serial Clock

// Create a DS1302 object.
DS1302 rtc(kCePin, kIoPin, kSclkPin);

String dayAsString(const Time::Day day) {
switch (day) {
case Time::kSunday: return "Sunday";
case Time::kMonday: return "Monday";
case Time::kTuesday: return "Tuesday";
case Time::kWednesday: return "Wednesday";
case Time::kThursday: return "Thursday";
case Time::kFriday: return "Friday";
case Time::kSaturday: return "Saturday";
}
return "(unknown day)";
}

void printTime() {
// Get the current time and date from the chip.
Time t = rtc.time();

// Name the day of the week.
const String day = dayAsString(t.day);

// Format the time and date and insert into the temporary buffer.
char buf[50];
snprintf(buf, sizeof(buf), "%s %04d-%02d-%02d %02d:%02d:%02d",
day.c_str(),
t.yr, t.mon, t.date,
t.hr, t.min, t.sec);

// Print the formatted string to serial so we can see the time.
Serial.println(buf);
}

} // namespace

void setup() {
Serial.begin(9600);

// Initialize a new chip by turning off write protection and clearing the
// clock halt flag. These methods needn't always be called. See the DS1302
// datasheet for details.
rtc.writeProtect(false);
rtc.halt(false);

// Make a new time object to set the date and time.
// Sunday, September 22, 2013 at 01:38:50.
Time t(2013, 9, 22, 1, 38, 50, Time::kSunday);

// Set the time and date on the chip.
rtc.time(t);
}

// Loop and print the time every second.
void loop() {
printTime();
delay(1000);
}

set_clock.ino (2.07 KB)

Have you tried writeRam(), readRam() to see if they work?

That will test you can actually do writes.

You do have pullups somewhere on the I2C bus of course?

You do have pullups somewhere on the I2C bus of course?

That library uses some pseudo-SPI interface.

Please provide a wiring diagram or a (sharp) photo of your setup. Also post a link to the breakout board you're using (many of them have problems with the crystal).

What type of Arduino are you using?