I have a Nodemcu with which i'm doing a project. So whenever there is a power loss i want values of some of the variables to not be reset, because of that im trying to store the values in EEPROM of the nodemcu. But the problem is i want to know if the EEPROM will get reset when a new code is uploaded and also since the nodemcu stores wifi credentials in the EEPROM i dont want to accedentally select an EEPROM address in which the wifi credentials are stored and cause a problem. Can anyone tell me the safe EEPROM addresses to use and also if EEPROM will get rest if a new code is uploaded?
1 Answer
The esp family chips do not have EEPROM. Instead they just dedicate a small section of flash to pretend to be EEPROM.
That flash section, depending on the core version, is either a dedicated EEPROM partition, or a dedicated key in the nvram partition. Either way it's separate to the wi-fi credentials, which are stored in their own key in the nvram partition.
EEPROM can be erased when you upload code if the partition layout changes. It's less likely to be erased if it's a newer version of the core where it's stored in the nvram.
For safety, don't change the partition size, and ideally use ArduinoOTA which will never change the partitions or erase the nvram.
-
and in Tools menu don't set "Erase flash" to "All flash content"– Juraj ♦Commented May 22, 2021 at 9:03