EEPROM on Nano ESP32: how?

Hi all,

EDIT: SOLVED. SEE BELOW

I used EEPROM to save a setting (message for a scrolling display) using a regular Nano, and that worked.

The same code, namely #include <EEPROM.h>, and then EEPROM.write(0, messageNumber); and later messageNumber = EEPROM.read(0), does not work on a Nano ESP32.

Should it still work? If so, any idea how?

(I have of course first searched, both this forum and Google).

Thanks!
M


Solution: I need to allocate EEPROM

EEPROM.begin(256);
delay(500);

And then also do a EEPROM.commit after I write to EEPROM. I am not sure that last step is actually necessary (yet), but it does no harm.

1 Like

I thought i remember reading EEPROM.h was not a good idea to use with Nano ESP32 as they do not truly have an eeprom…

i believe you may want to look into start using <preferences.h> to store into the flash properly…

Im by no means a coder and if its working for you then stick with your original ideA, just maybe the data may be corrupted down the road???

Take care

Thanks. I’ve found very little good info, so I hope someone here can point me in the right direction, if there’s a better way.

That is a common problem as the EEPROM is non existent but simulated in RAM and saved in flash. You need to commit the EEPROM to flash with this statement"
EEPROM.commit();, for more information check ESP32 Flash Memory - Save Permanent Data | Random Nerd Tutorials

1 Like

Again… no coder here and not sure what outdated and deprecated means

In that very link you provided, at the top, he specifically states it is outdated and deprecated and to use <preferences.h>,,,

Excellent! I’ll give that a go.

1 Like