I try to change time on windows to test my programing condition but RTC usually keep old time when i change time on windows and re-upload the code . I'm also removing the battery and cut the power it is still not working.
here is my set up and library is https://github.com/adafruit/RTClib
void setup () {
#ifndef ESP8266
while (!Serial); // for Leonardo/Micro/Zero
#endif
Serial.begin(9600);
Serial.println("ESP start...");
pinMode(Ledpin, OUTPUT);
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer, HIGH);
delay(3000); // wait for console opening
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, lets set the time!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
}
rtc.adjust(DateTime(F(__DATE__),F(__TIME__)));
construction, which uses theDateTime(char*,char*)
routine from github.com/adafruit/RTClib/blob/… and the C environment variables__DATE__, __TIME__
-- Rather than re-upload the code, you might need to re-compile to code to update the time encoded in the binary file.