EEPROM DATA GET ERASED WITH ARDUINO POWERDOWN?

Hi People,
I will appreciate some help from the clever guys, I’m not a master at programming so please be gentle :slight_smile: .

I’ve been struggeling quite a while with getting this to work. I’m working on a automatic Gen controller for my small gen at home. All works fine except for the part where I save the "lastruntime, totaltime and Lifetime hour’s. This values is always displayed on my graphical display.

It worked fine (using EEPROM.read and EEPROM.write) and saved the values perfectly until I realized it overflows at 255 minutes. Hence I explored the EEPROM.get and EEPROM.put.

Using this it also works fine. I can display values as big as I want. It stores it and updates the values after each run perfectly, however when I power OFF the EEPROM resets to ZERO.

Attached is the parts of my code involved in the EEPROM, I can load the whole program if needed. Am I implementing it correctly?
Thanks in advance.

#include <EEPROM.h>             //LIBARY FOR EEPROM SAVE

int eeAddress ;   //Location we want the TOTAL HOUR data to be put.
int eeAddress1 ;   //Location we want the LIFE HOUR data to be put.
int eeAddress2 ;   //Location we want the LAST RUN data to be put.

void loop() {    //main loop to run


  UpdateScreen();
  RunTime();

}

void UpdateScreen() {
      
  u8g2.clearBuffer();          // clear the internal memory 
  
  u8g2.setFont(u8g2_font_micro_tr); // choose a suitable font
  u8g2.setCursor(0,52);
  u8g2.print("LAST");

  u8g2.setCursor(0,58);
  u8g2.print("SINCE RESET");

  u8g2.setCursor(0,64);
  u8g2.print("LIFETIME");


  u8g2.setFont(u8g2_font_micro_mr); // choose a suitable font  
  u8g2.setCursor(11,46);
  u8g2.print("HOUR METER");  

  
  u8g2.setFont(u8g2_font_blipfest_07_tn); // choose a suitable font  
  u8g2.setCursor(47,52);
  u8g2.print(lasthour);
  u8g2.setCursor(54,52);
  u8g2.print(":");

  u8g2.setCursor(59,52);
  u8g2.print(lastmin);
  
  u8g2.setCursor(47,58);
  u8g2.print(tothour);
  u8g2.setCursor(54,58);
  u8g2.print(":");
  u8g2.setCursor(59,58);
  u8g2.print(totmin);
  

  u8g2.setCursor(47,64);
  u8g2.print(lifehour);
  u8g2.setCursor(54,64);
  u8g2.print(":");
  
  u8g2.setCursor(59,64);
  u8g2.print(lifemin);
 

  lasthour = totallastrunTime /60;   //get only the hours
  tothour = totaltotalTime /60;      //get only the hours
  lifehour = totaltotalTime1 /60;    //get only the hours
    
  lastmin = totallastrunTime % 60;   //get only the hours
  totmin = totaltotalTime % 60;      //get only the hours
  lifemin = totaltotalTime1 % 60;    //get only the hours


  u8g2.sendBuffer();          // transfer internal memory to the display

void RunTime() {

   EEPROM.get(eeAddress, totaltotalTime);
   EEPROM.get(eeAddress1, totaltotalTime1);
   EEPROM.get(eeAddress2, totallastrunTime);

  byte currentState = digitalRead(GEN_AC);
  if (currentState == LOW && lastState == HIGH) {
    startTime = millis();

  }

  if (currentState == HIGH && lastState == LOW) {
    totallastrunTime = (millis() - startTime) / 1000 / 60 ; //runtime in HOURS
    totaltotalTime = totaltotalTime + totallastrunTime; //to be saved to EEPROM
    totaltotalTime1 = totaltotalTime1 + totallastrunTime; //to be saved to EEPROM, non resetable
    EEPROM.put(eeAddress, totaltotalTime);
    EEPROM.put(eeAddress1, totaltotalTime1);
    EEPROM.put(eeAddress2, totallastrunTime);
    
    if(totallastrunTime > 0){
    EEPROM.put(eeAddress2, totallastrunTime);
    }
  }

  lastState = currentState;

}

Found my problem, didn't specify EEPROM addresses.....

int eeAddress = 0 ;   //Location we want the TOTAL HOUR data to be put.
int eeAddress1 = 10 ;   //Location we want the LIFE HOUR data to be put.
int eeAddress2 = 20 ;   //Location we want the LAST RUN data to be put.