Log to EEPROM after Reset

Hello,

I am trying to log a timestamp and EventCode (together 4Byte) into EEPROM, that functions properly.
Now i am trying to get the program jump to the last write after reset, to continue from there. Means: After Reset my timestamp should write 0:00:00 and EventCode after the last write before reset.
The problem ist, that after reset it overwrites and logs again from the beginning.
I tried to "write" NULL to my Log Area before starting the program to detect the next NULL "value" and write to that. Below is my program, i hope u can help me.
I am sorry for my english, i hope my problem is understandable

void logMsg(int EventCode) {
bool writeLog = true;
while (writeLog == true) {
if (EEPROM[addr] == NULL) { //Vermeide √úberschreiben, falls z.B vorher Stromversorgung unterbrochen wurde
EEPROM.write (addr, hour());
addr++;
EEPROM.write (addr, minute());
addr++;
EEPROM.write (addr, second());
addr++;
EEPROM.write (addr, EventCode);
addr++;
writeLog = false;
}
else {
addr++;
}
}
}

thank you and greetings,
NoobVorformatierter Text

Your code is incomplete.
Please remember to use code tags when posting code

Hello, sorry i tagged it now.

But it is still incomplete

if (EEPROM[addr] == NULL) { //Vermeide √úberschreiben, falls z.B vorher Stromversorgung unterbrochen wurde
EEPROM.write (addr, hour());
addr++;

if either hour, minute or second (or eventcode) == 0 the date will be overwritten.
we have to assume you are writing only 8 bit values. You would anyway be better off either writing 7-bit values where bit 7 is always high once it is in use, or using a different marker for 'next available address'

That would be an excellent reason to use 32 bit Epoch times.

1 Like

ok!