About DS1302 RTC module

I wanted to build a digital clock. But the RTC module is only showing this:
Current Date and time: 2000/0/0 0:0:0

Current Date and time: 2000/0/0 0:0:0
Sometimes, it gives the real time but it shows only single line the correct time then again the above line appears. I moves the wire connections but in vain.

#include "virtuabotixRTC.h" 
	 
#define DS1302_CLK_PIN A4 
#define DS1302_DAT_PIN A5
#define DS1302_RST_PIN 13 
	 
#define CURRENT_SECONDS 45 
#define CURRENT_MINUTES 30 
#define CURRENT_HOURS 11 
#define CURRENT_DAY_OF_WEEK 1 
#define CURRENT_DAY_OF_MONTH 6 
#define CURRENT_MONTH 11 
#define CURRENT_YEAR 2023 
	 
virtuabotixRTC RTC(DS1302_CLK_PIN, DS1302_DAT_PIN, DS1302_RST_PIN); 
	 
void setup() 
{ 
	 Serial.begin(9600); 
	 
	 // Once the battery is installed, 
	 // the module stores the value in memory 
	 RTC.setDS1302Time( 
	   CURRENT_SECONDS, 
	   CURRENT_MINUTES, 
	   CURRENT_HOURS, 
	   CURRENT_DAY_OF_WEEK, 
	   CURRENT_DAY_OF_MONTH, 
	   CURRENT_MONTH, 
	   CURRENT_YEAR 
	 ); 
} 
	 
void loop() 
{ 
	 // Allow updates of variables 
	 RTC.updateTime(); 
	 
	 Serial.print("Current Date and time: "); 
	 
	 Serial.print(RTC.year); 
	 Serial.print("/"); 
	 Serial.print(RTC.month); 
	 Serial.print("/"); 
	 Serial.print(RTC.dayofmonth); 
	 
	 Serial.print(" "); 
	 
	 Serial.print(RTC.hours); 
	 Serial.print(":"); 
	 Serial.print(RTC.minutes); 
	 Serial.print(":"); 
	 Serial.print(RTC.seconds); 
	 
	 // New line 
	 Serial.println(); 
	 
	 // Add one second delay between iterations 
	 delay(1000); 
} 

Can you please give some advice?

I would try another library to see if the problem remains... arduino-ds1302/examples/set_clock/set_clock.ino at master · msparks/arduino-ds1302 · GitHub

Do you have DS1307 RTC Module or DS3231 RTC Module? I have no DS1302 RTC to explore your problems.

It is DS1302.

I tried now. The output is:
(unknown day) 2000-00-00 00:00:00

#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   = 12;  // Chip Enable
const int kIoPin   = A5;  // Input/Output
const int kSclkPin = A4;  // 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);
}

I used the example code.

What happens if you run the i2c scanner sketch (from the examples menu)?

Hi! welcome to the Forum.

Which board are you using?

On an Uno, SDA is A4 and SCL is A5. Pin 13 is connected to the onboard LED.

DS1302 is not an I2C device. It is controlled by a 3-wire proprietory protocol (CE/RST, I/O, SCLK), which can be assigned on any convenient DPins.

You mean is not.

I remember now. DS1307 is i2c, DS1302 is not.

@abrar77 forget my suggestion of i2c scanner.

Use DS1307 or better still DS3231.
Use a library like RTCLib and checkout the many guides available.
Adafruit guide is good.
It will work.

Eaxctly! Thank you to point at the missing adverb.

Text seems to indicate use of an internal oscillator references external.

http://datasheets.maximintegrated.com/en/ds/DS1302.pdf

Can you post a picture of your wiring?

If the DS1302 is on a board that came without headers, did you solder the header pins on or just stick wires through the holes?