Save byte value to nodemcu eeprom

I am looking for a solution to save byte value to nodemcu eeprom when power loss
is there any code and circuit diagram?

NodeMCU has no EEPROM.

The EEPROM library, for ESP8266 boards, uses some Flash memory to emulate EEPROM.

You can add an external EEPROM chip to NodeMCU.

s-l400 (37)

Which do you need help with?

You need a power monitoring circuit to detect when the voltage level falls a given threshold level and then to interrupt the MCU for storing the critical data into EEPROM.

do you have circuit diagram & code to test?

Does you NodeMCU contain BOD (Brownout Detection) Circuit?

I just have nodemcu board

Just to clarify... are you ...

  1. Just wanting to know how to read/write to the EEPROM so data is retained after power loss?

OR

2). Wanting to detect power failure, and then write to the EEPROM at that point ?

yes

You may try the following simplified model (Fig-1) to save critical data into EEPROM when Vcc (3.3V) reaches at 2.58V during power failure. 2.58 V is the minimum voltage level at which NdeMCU keeps working.
NodeMCUAnalogCh
Figure-1:

1. Build circuit as per Fig-1.
2. Adjust the POT to get about 0.70 V (0.9/3.3*2.58) at A0-pin.
4. Upload the following sketch (untested):

#include <EEPROM.h>
float x = 13.67;

void setup()
{
  Serial.begin(9600);
  Serial.println();
  EEPROM.begin(512);
}

void loop()
{
  int y = analogRead(A0);
  if ((float)y <= 0.7)
  {
    EEPROM.put(0, x); //saving 13.67 into EEPROM
    EEPROM.commit();
    EEPROM.end();
    while(1);   //wait for evver
  }
  else
  {
    //do other tasks
  }
}

is it possible to write into esp8266 eeprom inside interrupt routine?

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