-->
Page 1 of 1

Save data on power loss

PostPosted: Mon Dec 19, 2016 8:43 pm
by Fotonic
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.

Re: Save data on power loss

PostPosted: Tue Dec 20, 2016 5:07 am
by Barnabybear
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).

Re: Save data on power loss

PostPosted: Tue Dec 20, 2016 1:26 pm
by Fotonic
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.