Hi, I need to store some variables and retrieve them also when power goes down: may I do this in an ESP8266 (and in ESP32) at runtime? Without an external flash card I mean.
Thanks.
Hi.
Yes.
You can use the EEPROM library to save variables permanently.
Then, at the beginning of you code read the variables saved on the EEPROM.
Learn more here: https://arduino-esp8266.readthedocs.io/en/latest/libraries.html#eeprom
We have a tutorial about that with the ESP32: https://randomnerdtutorials.com/esp32-flash-memory/
I hope this helps.
Regards,
Sara
Thanks Sara,
I need it in uPython but following your hint I found this: https://github.com/dda/MicroPython/blob/master/EEPROM.py.
I’ll give it a try and let you know if it works. In the meanwhile if you know other uPython libs to read/write ESP 82266 EEPROM please let me know.
Have a nice day.
Enzo
Hi Enzo.
That library seems to be used with external EEPROM modules. I’m not sure if it works with the internal ESP32 flash memory.
Alternatively, you can create a file, write to the file, and then read the file if needed. See here: http://docs.micropython.org/en/latest/esp8266/tutorial/filesystem.html
Regards,
Sara
Hi Sara,
of course! Silly question! I didn’t think about this way.
Thanks a lot!
Enzo