2

I need to get some values saved into eeprom on my esp 8266, but it's not working. I get the Error "ERROR! EEPROM commit failed" when i try to EEPROM.commit() some writes. I tested it with my own code, but it also doesn't even work with the examples from the EEPROM library. I have multiple ESP8266MOD and tested with some of them, but no one worked. Anybody got an idea?

If you need additional Infos ill tell you

Marcel Stör
  • 22,695
  • 19
  • 92
  • 198
Bastibrot
  • 45
  • 6
  • Check here: https://arduino.stackexchange.com/questions/25945/how-to-read-and-write-eeprom-in-esp8266 – Nino Jul 16 '21 at 10:14
  • But even the examples don't work? – Bastibrot Jul 16 '21 at 12:23
  • Please add a link to your board, let's look at the spec. – Nino Jul 16 '21 at 12:30
  • It's the v3 https://m.de.aliexpress.com/item/1005001636634198.html?pid=808_0003_0109&spm=a2g0n.productlist.0.0.1eea71ffaplZVl&browser_id=4b1171acb1f84e1dbc0dcf61ba279fa3&aff_trace_key=fe7ff09087204b6d99be487ed5c287c0-1626446868278-02195-UneMJZVf&aff_platform=msite&m_page_id=4ncfgl6avyicabdh17aafc9dab5a113e60151cb274&gclid=&_imgsrc_=ae01.alicdn.com/kf/Hcb429d1a36af4d08a7b8dc4bfb5e3d17f.jpg_640x640Q90.jpg_.webp – Bastibrot Jul 16 '21 at 14:49
  • Are you sure it has built in EEPROM? If not you can use the flash to store data but remember it erased ech time you burn your code. – Nino Jul 16 '21 at 15:11
  • I think the eeprom gets emulated in flash, but don't know 100%. Could you name me library for using flash as storage? – Bastibrot Jul 17 '21 at 08:40

2 Answers2

2

As we discussed in the comments, it is not working because ESP8266 do not have EEPROM and your option is to use Flash to emulate the EEPROM.

I have not done a thorough research as I am not using ESP8266 on regular basis but did try the ESP_EEPROM library and it seem to be working well, here's the code I just tested:

#include <ESP_EEPROM.h>

void setup() {
  Serial.begin(115200);
  while(!Serial);
  EEPROM.begin(16); // looks like 16 bytes is the minimum
  EEPROM.put(0, 1234); // first parameter sets the position in the buffer, second the value
  boolean res = EEPROM.commit();
  Serial.println(res); // should print 1 (true) if commit worked as expected
  int myVar;
  EEPROM.get(0, myVar);
  Serial.println(myVar);
}


void loop() {
}
Nino
  • 702
  • 2
  • 6
  • 12
  • OK thank you a lot! I m sorry I can't test it now, but I'll try to execute it tomorrow. I'll give you an answer tomorrow too on this stack overflow question – Bastibrot Jul 17 '21 at 20:37
  • Thank you so much! I tried it and it works like a charm. I have one last question, don't know if you can answer it to me: How much space in bytes do I have now? In my thoughts it should be more than the initial eeprom 512 b. Or is it not? The library does only give you a percentage – Bastibrot Jul 18 '21 at 16:11
  • There's very good information in the library, I suggest you read it, and as you will see you have to be careful with both the size you allocate (should be very small) and how many commits you do during device lifetime (should be minimal or else it will kill the flash): https://github.com/jwrw/ESP_EEPROM/blob/master/src/ESP_EEPROM.cpp – Nino Jul 18 '21 at 16:44
  • Thank you very much! I hope i can help you some day maybe – Bastibrot Jul 18 '21 at 18:54
  • I had such issues : EEPROM.commit(); was not successful. I could fix it with change a Board. In my case : I changed Wemos D1 mini Pro to Wemos D1 mini (clone) and EEPROM had started to work. It seems my clone boards requires different presents. I did not dig into details about the exact reason of that. – Sergei Apr 21 '22 at 19:49
0

in some cases the problem is in the Arduino Ide Tools. For example, the Flash Size might be set to 512KB, and your device Flash Size might be 4MB. Then, you need to select in the Arduino Ide Tools, the correct size of your ESP. This problem happened to me, I thought there was a problem in muy code, but when I changed the Flash Size, the EEPROM start to work.

VIHPER
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 08 '22 at 04:36