Arduino EEPROM and last value with RTC

Hi, I am using an arduino328p, with a DS3231 RTC and a waterflow sensor. The values of the sensor MUST be printed in the arduino all the time the arduino is awake (Serial.print()). Because in anymoment the Arduino will lose connection with the battery (disconecting it by hand), I need the arduino to save in the EEPROM the last value given from the sensor. Then if the value is the same from 19.57 to 20.00 (with the RTC) when I power up the Arduino the EEPROM value and the Arduino must be set to 0. And then all over again.
I've been looking for a solution but after research nothing new.

THANKS