Save counter variable to esp8266

I want to save counter variable to esp8266 when power off how to do it?

Turn it on, save it, then turn it off again.

counter value is changeable so to save life of eeprom want to save counter value when power switch off to esp8266

So, save it somewhere that doesn't depend on turning the processor on.

writing to eeprom is limited so need when power loss to esp8266 so save the counter value and when esp8266 power return back so get last value then continue counting and so on

Use FRAM, SD card, whatever

No space in PCB to use SD card also Fram is limited, counter changed more than 300 times in a minute

Not entirely sure I see that as a limit.
YMMD.

Maybe make a notch on a stick?
A circular saw could manage quite a few of these in a minute.

Battery-backed RAM?

But if you don't have space for SD card, you probably won't have room for a battery backed RAM module either.

I want counter to be saved and not erased because of security so no one can reset the counter if use battery so counter will reset then it is useless

So what you need is memory which retains its value when there is no power, has unlimited writes in its lifetime and no limit to the number of writes per second, and requires no battery?

:thinking:

counter variable is changed while esp8266 power on then it must save last value to eeprom if power loss then after power on again then get value from eeprom and continue counting so this way can save eeprom life for writing, I am looking for this solution

Use a capacitor to keep the ESP8266 running for a few milliseconds after a power failure, and use a GPIO to detect the power failure.
When power fails, this GPIO signals to save the counter in the EEPROM and then the ESP8266 will naturally be turned off.

do you have circuit diagram and code to test?

Have a read here

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.