0

Does anyone know a way to call an interrupt when an Arduino loses power to have it fire a small function real quick?

It'd be a quick EEPROM write of one variable.

I know you can use interrupts on certain pins when they get pulled low, I'm just not sure if it's possible on the power pin.

Or if there would still be enough power in the controller to finish that function.

I have the Node MCU board but it's programmed in Arduino c++.

3

Not directly, no. When an Arduino or ESP8266 has lost power it's lost power. You need external circuitry to keep providing power after the power input has been removed, and alert your target chip that power has gone.

schematic

simulate this circuit – Schematic created using CircuitLab

C1 wants to be massive. The ESP8266, because of the WiFi interface in it, consumes a lot of power. Also, writing to EEPROM or Flash (which the ESP8266 has instead of EEPROM) takes extra power.

Ideally, C1 wants to be a small Super-Cap to keep the physical size small. For an ESP8266 you're probably talking thousands of uF.

An alternative is to use the 47L16 (or similar) EERAM chip which is designed to save its internal SRAM contents to internal EEPROM when power is lost using its own dedicated capacitor-based power reservoir.

| improve this answer | |
  • Does the 47L16 save to it's own internal EEPROM or to the EEPROM of the MCU? – Bigbob556677 Mar 13 '18 at 13:50
  • Internal. RTFM. – Majenko Mar 13 '18 at 13:50

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.