1307 rtc dislplaying 00:00:01 1/1/2000

I took the battery out of the RTC and now every time I deploy a program it shows the time and date as:

00:00:01

01/01/2000

Can someone please help me?

Here is a program that was working fine and now is not since the battery incident:

#include <LiquidCrystal.h>

#include <Time.h>
#include <TimeLib.h>

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

#include <Wire.h>
#include "RTClib.h"

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

RTC_DS1307 RTC;

void setup () {
Serial.begin(9600);
Wire.begin();
RTC.begin();
lcd.begin(16, 2);

if (! RTC.isrunning()) {
lcd.print("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
// uncomment it & upload to set the time, date and start run the RTC!
//RTC.adjust(DateTime(DATE, TIME));
}

}

void loop () {
DateTime now = RTC.now();
lcd.setCursor(0,0);
lcd.print(now.day(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.year(), DEC);
lcd.print(' ');
lcd.print(now.hour(), DEC);
lcd.print(':');
byte minute = now.minute();
if (minute < 10)
{
lcd.print("0");
}
lcd.print(now.minute(), DEC);
lcd.print(':');
byte second = now.second();
if (second < 10)
{
lcd.print("0");
}
lcd.print(now.second(), DEC);
}

The RTC needs the battery so it can keep updating the time when power is removed. Put a battery back in, write some code to set the time (via LCD and buttons or via serial port) and you're good to go again.

This is what I attempted and it was unsuccessful :frowning:

I have put the battery back in and deployed multiple programs and it seems to be stuck on this time and date now.

ao90:
I took the battery out of the RTC and now every time I deploy a program it shows the time and date as:

00:00:01

01/01/2000

Can someone please help me?

What did you expect to happen with a clock without the battery?

If you look at the middle of your sketch,

   // following line sets the RTC to the date & time this sketch was compiled
   // uncomment it & upload to set the time, date and start run the RTC!
   //RTC.adjust(DateTime(__DATE__, __TIME__));

That is instructions on how to set the time in the RTC. Time will be a little off, as it takes a few seconds from compile until sketch is uploaded and executed. After you have the time set, you need to put those comments back and upload again. If you don't time will start from the same time and date every time you are powering up your Arduino.

1 Like

Thanks, apologies I am not very good at programming.