0

I'm trying to implement more memory writing lifespan when storing a single Boolean Value using ESP8266 integrated (flash) memory with Arduino EEPROM library. A single hardware memory location cannot be changed infinitely and I'm trying to find out an efficient solution to extend the lifespan of the memory usage write cycles on several different (similar) platforms.

Some sources determines that the actual write cycle amount of a single EEPROM memory (bit) location is approx 100k - 1M writes (of course this varies much depending on what hardware is being used). One test I found measured 9584038 passed write cycles with Arduino but still I want to extend the memory write cycles if possible.

As far as I know it is impossible to access single bits with EEPROM library and you are limited just storing and reading 8-bit byte values.

The simplest solution for storing a boolean value with the Arduino EEPROM library could be just store FALSE as a 0 value and TRUE as a 1 (for eg.).

The question is: Does this kind of ("bit-shifting") approach (image below) make any difference compared to just writing 0 and 1 values to a single Arduino EEPROM (8-bit) memory address. The idea behind this approach is just to change a single bit when changing the actual Arduino EEPROM memory (8-bit) address value when used as a Boolean value (reverse parity of bits 00000000 = false, 00000001 = true, 00000011 = false, 00000111 = true, etc.). Or should I drop the Arduino EEPROM library and do this other way? I've tried to figure out what's happening under the hood when using the Arduino EEPROM library and could not understand how it actually works inside the microchip.

description image attached

"Red Block" represents the changed bit - "DECVAL" is the actual stored Arduino EEPROM unsigned char value. So the actual stored (unsigned) char value cycle would be 0, 1, 3, 7 ... 224, 192, 128, 0, 1 ...

sam_v
  • 494
  • 1
  • 5
  • 12
  • Just for reference, how often do you expect to be changing this value? – romkey Mar 26 '21 at 00:49
  • esp8266 EEPROM library bundled with the boards support package emulates EEPROM in flash memory. flash memory can write only a whole page. flash supports 10000 writes – Juraj Mar 26 '21 at 09:06
  • @romkey actually it varies depending on the end-use-case, but I was planning something like 1-1000 changes a day, so that makes max 365 000 writes a year and the device should last also several years in use. Maybe I'll do a little experiment with a ESP8266 and wear out some memory locations differently and measure the max write cycles. – sam_v Mar 26 '21 at 22:18
  • https://www.esp32.com/viewtopic.php?t=6260#p27004 this actually tells more about how the flash writing mechanism possibly works. I'll experiment this some day and post here the results. – sam_v Mar 26 '21 at 22:34

0 Answers0