I suspect that your sketch is not seeing the RTC as running during setup(), and/or that you have not fitted the battery.
Try adding a delay(1000); before this
if (! RTC.isrunning()) {
But you need to give us a link to the RTC you are using
Mark
I suspect that your sketch is not seeing the RTC as running during setup(), and/or that you have not fitted the battery.
Try adding a delay(1000); before this
if (! RTC.isrunning()) {
But you need to give us a link to the RTC you are using
Mark