In my current project I need to store (among other things) the current elapsed time in hours to retrieve it in case of power loss. Since I am using a Arduino Nano I would ideally like to use the built in EEPROM without additional hardware.
The values are stored every hour and their order will always be:
0 → 1 → 2 → 3 → 4 → 5 → 6 → 0 → ....
If I write that on EEPROM per 0->0 full cycle the last bit will change 7 times and the other bits are pretty much idle. That's why I thought of distributing the changes more evenly by using instead the sequence
0 → 1 → 3 → 7 → 15 → 31 → 63 → 0 → ....
This would change every bit only once during a full 0->0 cycle. However after reading this post I think I need to work with zeros rather than ones, so
255 → 254 → 252 → 248 → 240 → 224 → 192 → 255
Now, I would like to clarify if
- the strategy works altogether, e.g. does this spread of changes to different bits indeed improve EEPROM life expectancy?
- I can use the EEPROM library function EEPROM.update() to realize the strategy?
Remark: I asked the same question on arduino.stackexchange but was redirected over here.
Remark2: While the specified 100000 cycles would roughly translate to 10 years of service, the question is still interesting for me since I would like ideally to switch to 5 or 10 minute intervalls (from hours)
Remark3: Since my EEPROM is not really used that much I could simply use 7 bytes to realize the strategy, however if possible I would like to understand the possibilities of a solution using just one byte for the sake of understanding how EEPROM works and a sense of "cleanliness".