I'm working on project which require to save some data into the EEPROM.
As I read online the ESP8266 has no real EEPROM, it use a section of FLASH just after the SPIFFS. Due to this read/write is quite different from standard Arduino, you need to call EEPROM.commit()
. You also have to call EEPROM.begin(size)
(I used size = 512) before start to use it.
I follow different tutorials online and I made some tests but it seems not working at all. When I try to save a value and then read it, values are different. I tried with
EEPROM.write(..)
...
EEPROM.read(..)
and with
EEPROM.put(..)
...
EEPROM.get(..)
but nothing change.
Is there any configuration on the board I need to set into Arduino IDE/Board Configuration?
EDIT: here's the code
void setup()
{
Serial.begin(9600);
Serial.println();
EEPROM.begin(512);
EEPROM.write(0, 62);
EEPROM.write(10, 103);
//EEPROM.commit();
EEPROM.end();
Serial.print("Read at 0:"); Serial.println(EEPROM.read(0), DEC);
Serial.print("Read at 10:"); Serial.println(EEPROM.read(10), DEC);
}
I always read 0 in the output.
read
only betweenbegin
andend
. it works with memory image.begin
allocates the in-memory image.commit
writes it to flash.end
commits and deletes the memory image