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


and with


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() 

    EEPROM.write(0, 62);
    EEPROM.write(10, 103);
    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.

  • why not just use SPIFFS? it's way simpler, far larger, and better organized.
    – dandavis
    Commented Jan 22, 2019 at 17:23
  • @dandavis I only need to store a few bytes, use a file system seems too much 'expensive' to achieve this simple task.
    – Noisemaker
    Commented Jan 22, 2019 at 17:44
  • It's not that expensive, and in fact, it has wear-leveling, which is (potentially) a huge long-term reliability benefit, especially when most of your blocks will be empty. It's not really a full file system, there's not even paths (just names), so it's more a fast key/value store of it's own right. I would try it and see if it bogs down your project; I can't image it would be much worse than EEPROM unless your doing something that will wear out either...
    – dandavis
    Commented Jan 22, 2019 at 17:47
  • you can read only between begin and end. it works with memory image. begin allocates the in-memory image. commit writes it to flash. end commits and deletes the memory image
    – Juraj
    Commented Jan 22, 2019 at 20:29
  • @Juraj thanks a lot! For me it's the best answer. It works and now I understande the reason. Btw it is not very well documented this procedure.
    – Noisemaker
    Commented Jan 23, 2019 at 18:20

2 Answers 2


You can read the emulated EEPROM only between begin and end. It works with memory image.

  • begin allocates the in-memory image.
  • commit writes it to flash.
  • end commits and deletes the memory image.

Here is some ESP8266 example code to store and read strings from EEPROM data:

#include <EEPROM.h>

void writeString(char add,String data);
String read_String(char add);

void setup() {
  // put your setup code here, to run once:

  EEPROM.begin(512);  // Note::

  String data = "Hello World";

  Serial.print("Writing Data:");

  writeString(10, data);  //Address 10 and String type data

void loop() {
  // put your main code here, to run repeatedly:
  String recivedData;
  recivedData = read_String(10);
  Serial.print("Read Data:");

void writeString(char add,String data)
  int _size = data.length();
  int i;
  EEPROM.write(add+_size,'\0');   //Add termination null character for String Data

String read_String(char add)
  int i;
  char data[100]; //Max 100 Bytes
  int len=0;
  unsigned char k;
  while(k != '\0' && len<500)   //Read until null character
  return String(data);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.