You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems, that the EEPROM-methods are used the same way as on an AVR based Arduino.
This will not work in this way. I came upon that problem when using an AVR based sketch on an ESP32. The EEPROM class exists for compatibility purpose (exactly this usecase), but need a little extra effort to work propperly.
The compiler will not throw a warning or so, all seems to be all right, but it will not.
An EEPROM size must be defined:
#define EEPROM_SIZE 128 // Emulate 128 bytes of EEPROM
As far as i see this can be not more than one sector of an ESP32 FLASH which means 4kB.
The EEPROM must be initialized:
if (!EEPROM.begin(EEPROM_SIZE))
{
Serial.println(F("Failed to initialise EEPROM!"));
}
The EEPROM content must be "commited" to be persistent after using EEPROM.write() (whenever it is useful and not to exceed the maximum FLASH write cycles):
EEPROM.commit();
As far as i see, RAM memory is allocated as an EEPROM emulation. At initialization the FLASH area is read into that emulation memory. EEPROM manipulation is done within that RAM emulation memory. So if you don't commit, the EEPROM content isn't stored persistent.
Be aware, that EEPROM.length() will not work propperly with the standard initialization!
So i suppose, that the EEPROM content is lost after a suppy interruption with the current sketch...
Regards, Thorsten
The text was updated successfully, but these errors were encountered:
It seems, that the EEPROM-methods are used the same way as on an AVR based Arduino.
This will not work in this way. I came upon that problem when using an AVR based sketch on an ESP32. The EEPROM class exists for compatibility purpose (exactly this usecase), but need a little extra effort to work propperly.
The compiler will not throw a warning or so, all seems to be all right, but it will not.
An EEPROM size must be defined:
As far as i see this can be not more than one sector of an ESP32 FLASH which means 4kB.
The EEPROM must be initialized:
The EEPROM content must be "commited" to be persistent after using EEPROM.write() (whenever it is useful and not to exceed the maximum FLASH write cycles):
As far as i see, RAM memory is allocated as an EEPROM emulation. At initialization the FLASH area is read into that emulation memory. EEPROM manipulation is done within that RAM emulation memory. So if you don't commit, the EEPROM content isn't stored persistent.
Be aware, that EEPROM.length() will not work propperly with the standard initialization!
So i suppose, that the EEPROM content is lost after a suppy interruption with the current sketch...
Regards, Thorsten
The text was updated successfully, but these errors were encountered: