RV1805 time resets to compile time upon power loss to the RTC

New to this product and building a low power datalogger with a barebones ATmega238p.

I wanted to test how the RTC would behave upon the whole system losing power from the battery pack. I hoped the supercap on the RV1805 would sustain the time keeping throughout the power loss, but the time resets to the compile time of the sketch.

Am I missing something obvious here or is this abnormal behaviour from the breakout board?

Cheers :slight_smile:

Are you using the library linked for the RV1805? There is a function “setToCompilerTime()” which is doing that.

Hi there, forgive me if I didn’t explain myself very well!

I have the code set up to set the RTC to the compile time (as you say with “setToCompilerTime()”, that bit is fine and working as intended. However, once running, should the RTC become disconnected from power it loses its current time and defaults back to the compile time. I’m interested to know if this is as expected? I was hoping the supercap on the board would sustain the timekeeping throughout a powerloss for 30 or so days?

Cheers

How does your code skip the call to “setToCompilerTime()” when starting up after a power fail?

If setToCompilerTime() is in your sketch, it’s going to reset the clock to that original compile time every time the sketch runs. What you want to do is write one sketch to set the clock, then disconnect the RV1805 and upload another sketch that just reads the time. Once that’s loaded, reconnect the RV1805 and you should be fine from there on.

I’ve just read the two comments above and had a proper “DUH!” moment. I see the issue now with the setToCompileTime resetting the clock because that’s just how code works…

Sorry for the obvious question, will go and have another go.

Thanks for the help!

I have code that gets the time from the RTC and I only set the RTC to compile date/time if the date on the device isn’t valid.