I use Arduino mega with Ds1307. I have the following problem.
Time works only as long as power is connected to the plate.
When you switch off, and after a while turn back the clock is not more accurate.
Where is the problem???
This is my code:
// Date and time functions using just software, based on millis() & timer
#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
RTC_Millis RTC;
void setup () {
Serial.begin(57600);RTC.begin(DateTime(DATE, TIME));
lcd.begin(20, 4);}
void loop () {
DateTime now = RTC.now();Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();lcd.setCursor(0, 1);
lcd.print(now.hour(), DEC);
lcd.print( " " );lcd.setCursor(6, 1);
lcd.print(now.second(), DEC);
lcd.print( " " );lcd.setCursor(3, 1);
lcd.print(now.minute(), DEC);
lcd.print( " " );lcd.setCursor(2, 1);
lcd.print(":");lcd.setCursor(5, 1);
lcd.print(":");Serial.println();
delay(500);
}