2

I want to store a counter that is always changing, but I want it to remain and being able to retrieve it on after a power loss. It's only one long number data, but as it is always changing, I don't know where to store it to not over wear the memory space ?

I'm aware that writting to much on ESP's eeprom or SPIFFS would damage it.I've seen that post, but it doesn't help in my case.

The data to be saved is the volume of water pumped with a water pump during it's entire life. Of course I could save it only once a while to reduce the number of writting, but I would loose some acccuracy.

2
  • 1
    As far as I can see SPIFFS does wear leveling. To get a ballpark number of counter updates you can do before you have to think about wear. Get the size of the SPIFFS volume. Divide that by the sector size of the SPI flash (see datasheet). Multiply that by the number of cycles the datasheet specifies for it's endurance. My guess is, your pump has to run for millennia before you can expect problems with the flash.
    – Gerben
    Nov 9 '20 at 19:59
  • you could save it to rtc memory each read, and to spiffs (which is wear-leveled) every 10 reads. That would let you lossless-ly resume from brief power interruptions, and balance long-term precision with reliability.
    – dandavis
    Nov 12 '20 at 8:16
1

A local solution would be to use EERAM. This is an EEPROM and an SRAM coupled together with some intelligent power management circuitry - writes get stored in SRAM until the power goes (or an instruction to save is sent) when the contents of SRAM get copied into EEPROM using the power stored in a large capacitor.

A good choice is the 47C16 (5V) or 47L16 (3.3V).

1

If you worry about the maximum number of write cycles, you could write the data to an SD card or some FRAM connected to the ESP8266, or you could send the data to a (web) server (if you have access to one) using WiFi. The server can then store the data.

If you really care about the data, you could do both. Having a backup is the only protection against catastrophic failure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.