/*
*/
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
void setup()
{
Serial.begin(9600);
Wire.begin();
RTC.begin();
RTC.adjust(DateTime("JAN 19 2014","16:45:45"));
}
void loop()
{
DateTime now = RTC.now();// Getting the current Time and storing it into a DateTime object
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(1000);
}
I would like to be able to set the start time (like I have done in my code) but then want the ds3231 to keep the time when it is removed and then plugged back in. So whenever I plug it back in it will display the correct time and not carry on from what the time was last or start again from the start time. is this possible? and please post code that i can copy and paste into my code rather than tell me what to write because I'm not very good with code and probably won't understand!
I would like to be able to set the start time (like I have done in my code) but then want the ds3231 to keep the time when it is removed and then plugged back in. So whenever I plug it back in it will display the correct time and not carry on from what the time was last or start again from the start time.is this possible?
Of course it is. Do you have some code that does not set the time, but does read it? Why not?
You can use that code, as a matter of fact. Simply comment out the call to set the time. See what happens.
Hello,
Thanks Paul, I have trailed what you suggested but the time resets to the 1/1/2000 0:0:00. Also I do have code that can read the time but I have the same problem.
Thanks John, I simply mean removing all wires from the ds3231 (yes it's a fully assembled rtc), and then putting them all back in.
I have done some tests and found that the ds3231 doesn't keep time when the ground is unplugged, but if you unplug and then re-plug in all the other pins the ds3231 keeps the time and displays the correct time. any help?