Hey Guys, since eeprom has a limited life cycle, is there a way that you can detect that the power is about to go out( using brown out or something) so that it interrupts the code, and writes the current variables into eeprom just before you lose complete power? Trying to avoid the use of a back up battery and an SD card...
is there a way that you can detect that the power is about to go out
No. You can only detect when the power has gone out, and then only if you have an alternate power source than can power the Arduino for a second or two, while it saves the data.
The physics of how EEPROM works is a little different to the main memory and guess what - EEPROM writes use extra electricity. That is, a millisecond into a brownout, when supply has fallen to about 4V, an EEPROM write is least likely to work.
Can you have a think about the cost and complexity of providing say, 9V to a big fat capacitor or supercapacitor at Vin, and measuring the analogVoltage halfway down from that with a 22kOhm22kOhm potential divider to an analogInput pin. In principle, that could be set to start an EEPROM write when the capacitor falls to 8V. How big a capacitor do you need to have completed your EEPROM writes before it falls to 7V ?