Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By Fotonic
#59718 Hi, I'd like to save the last state of some variables in flash when powered off.
Is there any way to do so?
I am thinking of a power capacitor to buffer power line and using an Input line of the ESP to monitor power state before the capacitor (and a diode I suppose) and trigger data saving when power is lost and, hopefully, before capacitor discharges.
Any other ideas? I't all for avoiding excessive flash memory writes since data is refreshed every second.

Thanks.
User avatar
By Barnabybear
#59729 Hi, thats about it. As another option if you used a rechargeable cell you could try to power through the power fail and still have the option to save if the cell looked like being flattened. With the ESP8266-12 series ADC is broken out and could check the cell voltage (it only measures 0 to 1V dc though so you would need to adjust accordingly).
User avatar
By Fotonic
#59755
Barnabybear wrote:Hi, thats about it. As another option if you used a rechargeable cell you could try to power through the power fail and still have the option to save if the cell looked like being flattened. With the ESP8266-12 series ADC is broken out and could check the cell voltage (it only measures 0 to 1V dc though so you would need to adjust accordingly).


It's powered by a 5V usb charger so cap + sensing input voltage should be the way to go for me.
I need to find a way to cut off the energy hungry parts like WS2812 for example so the cap only provides backup for ESP module but this should be easy to do.