Need URGENT help!

I would go for EEPROM - Arduino Playground - LibraryForI2CEEPROM -

The most important thing is to write e.g. in the first EEPROM position what the last address used.
(note this should be done with a separate sketch)

If the Arduino reboots it just can reads where it was left

  • OK there is always a small room for failure -

The essence of the code will be something like:

I2C_eeprom ee(0x50);

struct 
{
  unsigned ling tim;
  float tem;
  float hum;
} measure;

int position = 64;  // start on the 2nd page of the EEPROM to minimize wear in data-pages
void setup() 
{
  Serial.begin(115200);  // used for testing only
  Serial.println("Demo flight ");
}

void loop() 
{
  if (time to sample)  // see blink without delay
  {
    measure.tim = millis();
    measure.tem = readTemperature();
    measure.hum = readHumidity();
  
    ee.readBlock(60, (uint8_t*)position, 2);
    ee.writeBlock(position, (uint8_t*) measure, sizeof(measure) );
    position += sizeof(measure);
    ee.writeBlock(0, (uint8_t*) position, 2);
}

a separate sketch can read the EEPROM and dump it to serial