Datasheet
Whenever the RTC chip loses all power (including the backup battery) it will reset to an
earlier date and report the time as 0:0:0 or similar. The DS1307 won't even count seconds
(it's stopped).Whenever you set the time, this will kickstart the clock ticking.
So, basically, the upshot here is that you should never ever remove the battery once you've
set the time. You shouldn't have to and the battery holder is very snug so unless the board
is crushed, the battery won't 'fall out'
Setting the time
With the same sketch loaded, uncomment the line that starts with RTC.adjust like so:
if (! rtc.initialized()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
This line is very cute, what it does is take the Date and Time according the computer you're
using (right when you compile the code) and uses that to program the RTC. If your
computer time is not set right you should fix that first. Then you must press the Upload
button to compile and then immediately upload. If you compile and then upload later, the
© Adafruit Industries https://learn.adafruit.com/adafruit-data-logger-shield Page 38 of 85