Hi I want to create a function inside in my ESP8266 to clear or reset the eeprom
//Now Im setting this manually to TRUE to reset my eeprom
#define RESET_EEPROM false
if ( RESET_EEPROM ) {
for (int i = 0; i < 512; i++) {
EEPROM.write(i, 0);
}
EEPROM.commit();
delay(500);
}
Now I want to make this Upon click the external button of ESP8266 reset button it will automatically reset the EEPROM without doing it manualy.
How will able to a create a trigger function if RST button click = true then the code above will process at the same time it will restart the esp8266
I mean after clicking the button this code will read? Basically it will reset the eeprom? seems like if I put it in the setup function once you disconnect the power from the ESP8266 it will read again and clear the eeprom right? I jsut want something if you click thats the time the function will be called
for (int i = 0; i < 512; i++) {
EEPROM.write(i, 0);
}
EEPROM.commit();
delay(500);
Are you suggesting that restarting the module will always clear EEPROM?
The ESP8266 family doesn't have genuine EEPROM memory so it is normally emulated by using a section of flash memory. With the standard library, the sector needs to be re-flashed every time the changed EEPROM data needs to be saved. For small amounts of EEPROM data this is very slow and will wear out the flash memory more quickly.
Technically yeah that's what I wanted to do. I'm only storing WiFi Credential to EEPROM. So if I click the RST btn it will clear the EEPROM. but seems like I really need to re-flashed based on what you said.
The preferred way is to sacrifice an I/O pin, configure as internal Pull-Up in setup and the last thing in setup is to read the pin to determine if it is pulled low by a jumper; if so, jump to the clear routine. This completely avoids unintended erasures.