EEPROM.writeDouble() is not Compiled in my ESP8266 Sketch

Being inspired by a post in this Section, I am requesting for step-by-step help in the process of including this file: arduino-esp32-master.zip in my IDE 1.8.9 and then have compiled my following sketch in my ESP8266 Board. (I down loaded the file and tried to include it using this tool: Add .ZIP Library... of the IDE; but, it did not help.)

#include<EEPROM.h>
int adr = 0x0000;
void setup()
{
  Serial.begin(115200);
  Serial.println();

  EEPROM.begin(512);
  double x1 = -1.156012116E-06;
  //-----------------------------
  EEPROM.put(adr, x1);
  EEPROM.commit();
  //------------------//EEPROM.end();
  double y1;
  EEPROM.get(adr, y1);
  Serial.println(y1, 15); //shows: -0.001156012116000 ==> -1.156012116E-03

  EEPROM.writeDouble(0x0064,x1);            //compilation error
  EEPROM.commit();
  double y2;
  EEPROM.readDouble(0x0064, y2);
  Serial.println(y2, 15);   
}

void loop()
{

}

GolamMostafa:
EEPROM.writeDouble() is not Compiled in my ESP8266 Sketch

GolamMostafa:
I am requesting for step-by-step help in the process of including this file: arduino-esp32-master.zip in my IDE 1.8.9

Are you compiling for an ESP8266 or an ESP32. If you're compiling for ESP8266, then what does that have to do with you installing the ESP32 core? If you're compiling for ESP8266, it makes sense that you can't use the EEPROM.writeDouble(), since that function is only available in the ESP32 EEPROM library.

GolamMostafa:
I down loaded the file and tried to include it using this tool: Add .ZIP Library... of the IDE; but, it did not help.

That's a bad idea with this particular library. The reason is that the EEPROM libraries are architecture-specific. For this reason, each core bundles a version of the EEPROM library written specifically for its architecture. The libraries bundled with the core are only accessible when you are compiling for a board of that core. But when you do the Add .ZIP Library... installation of a library, it is installed for all boards. So this risks the Arduino IDE attempting to use the ESP32-specific EEPROM library on an architecture it was never meant to be used with. It can also cause you to end up using an outdated version of the EEPROM library even when compiling for an ESP32 board. So I recommend that you delete the EEPROM library from the libraries subfolder of your sketchbook folder. You can find the location of the sketchbook folder in the Arduino IDE at File > Preferences > Sketchbook location.

Since we're on the subject, are you sure you need the development version of the ESP32 core? Unless you are contributing to the development of the project or doing beta testing, I would recommend that you use the production release version of the core, following these instructions:
https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/boards_manager.md

pert:
Are you compiling for an ESP8266 or an ESP32.

I have been compiling for ESP8266 with an understanding that ESP8266 is the successor of ESP32 and their instructions should be the same though the processor types are a bit different (Tensilica LX6 for ESP32 and Tensilica L106 for ESP8266). (I don't own ESP32.)

If you're compiling for ESP8266, then what does that have to do with you installing the ESP32 core? If you're compiling for ESP8266, it makes sense that you can't use the EEPROM.writeDouble(), since that function is only available in the ESP32 EEPROM library.

Right! This particular method is not available in the EEPROM folder of the core esp8266/Arduino (Arduino-master.zip), which I have checked now.

Thanks with +1k.

GolamMostafa:
I have been compiling for ESP8266 with an understanding that ESP8266 is the successor of ESP32 and their instructions should be the same though the processor types are a bit different (Tensilica LX6 for ESP32 and Tensilica L106 for ESP8266).

This isn't about instructions. This is about the library API. I would also expect the API of the ESP8266 library and the ESP32 library to be the same. I'm not sure why they made them different. I don't have a lot of experience with ESP32 and the ESP32 core developers weren't kind enough to provide much in the way of documentation. It looks like all they give us is the readme:

EEPROM is deprecated. For new applications on ESP32, use Preferences. EEPROM is provided for backwards compatibility with existing Arduino applications. EEPROM is implemented using a single blob within NVS, so it is a container within a container. As such, it is not going to be a high performance storage method. Preferences will directly use nvs, and store each entry as a single object therein.

It's funny that they claim it's provided for "backwards compatibility with existing Arduino applications", but then they added a bunch of non-standard functions to the API, which will result in code written for ESP32 being non-portable.

The ESP8266 developers did a much better job of documentation:
https://arduino-esp8266.readthedocs.io/en/2.6.2/libraries.html#eeprom
It's not complete documentation, but that's because they only need to document what's different from the official Arduino EEPROM API, which is already documented here:
https://www.arduino.cc/en/Reference/EEPROM

pert:
I'm not sure why they made them different.

They are different means: ESP32-EEPROM contains EEPROM.writeDouble() method, and ESP8266-EEPROM does not contain.

Now, to store/retrieve double type float data into the EEPROM of ESP8266, we have to use put()/get() methods.

Sure, you can use EEPROM.writeDouble() with the ESP32 library if you like, but it also has put() if you want to write portable code. I like the simplicity of the standard EEPROM API.

Using this directive: #include<EEPROM.h> in the sketch, are we invoking the same EEPROM Library that comes with esp/arduino-master.zip for data read/write operation with the EEPROMs of both ATemega328P and ESP8266?

No. The Arduino AVR Boards core comes with its own EEPROM library bundled. As I said, the Arduino IDE only makes the libraries bundled with a core available when a board of that core is being compiled for. This allows each core to use its own version of the architecture-specific libraries like EEPROM, SPI, Wire, SoftwareSerial. This often isn't obvious to the user because the libraries usually have the same API. The EEPROM library bundled with the ESP32 core wouldn't work for the ATmega328P. Here is the AVR EEPROM library:

First, the ESP32 has a more advanced feature set then a ESP8266: API Reference - ESP32 - — ESP-IDF Programming Guide latest documentation. An example would be that the ESP8266 is a single core unit the ESP32, actually, has 3 cores. The ESP32, really, does not have an EEPROM.

One might consider using one of the ESP32's storage API's:Storage API - ESP32 - — ESP-IDF Programming Guide latest documentation

The ESP8266 also doesn't have EEPROM. It is using flash to emulate EEPROM. This is the reason why it was necessary to add a few additional functions to the ESP8266 EEPROM library API (to allow the user to avoid excessive wear on the flash memory).

Yup, that's all here in the ESP8266 Docs: https://www.espressif.com/sites/default/files/documentation/2c-esp8266_non_os_sdk_api_reference_en.pdf and the ESP32 docs, link posted earlier, about no EEPROM and using the Wear Levelling API, and using the various storage schemes available to both devices.

1. I am have been[edit] interested to know if the emulated EEPROM of ESP8266 (not ESP32) and the EEPROM of ATmega328P do use the same EEPROM Library which is located in the following path of my PC: [edit: emulated word is added]

C:\Program Files(x86)\Arduino\hardware\arduino\avr\libraries\EEPROM [edit: avr was dropped]

2. In my PC, the following are also the paths where various libraries are found/got included; but, I have not found any EEPROM folder in any path except that one of Step-1.

C:\Users\siam\Documents\Arduino\libraries
C:\Program Files(x86)\Arduino\libraries

3. I downloaded esp/arduino-master.zip file and found an EEPROM folder which contains this method: EEPROM.commit() -- a method that is not seen in the EEPROM folder of Step-1.

4. In the following ESP8266 sketch if I include or not the EEPROM.commit() method, the sketch us compiled, uploaded, executed, and gives the expected result.

#include<EEPROM.h>
int adr = 0x0000;
void setup()
{
  Serial.begin(115200);
  Serial.println();

  EEPROM.begin(512);
  double x1 = -1.156012116E-06;
  //-----------------------------
  EEPROM.put(adr, x1);
  //EEPROM.commit();
  //------------------//EEPROM.end();
  double y1;
  EEPROM.get(adr, y1);
  Serial.println(y1, 15); //shows: -0.001156012116000 ==> -1.156012116E-03  
}

void loop()
{

}

Now, is it reasonable to conclude that the EEPROMs of both ESP8266 (not ESP32) and AVR use the same EEPROM Library of Step-1?

GolamMostafa:
1. I have been interested to know if the EEPROM of ESP8266 (not ESP32) and the EEPROM of ATmega328P do use the same EEPROM Library which is located in the following path of my PC:

C:\Program Files(x86)\Arduino\hardware\arduino\libraries\EEPROM

2. In my PC, the following are also the paths where various libraries are found/got included; but, I have not found any EEPROM folder in any path except that one of Step-1.

C:\Users\siam\Documents\Arduino\libraries
C:\Program Files(x86)\Arduino\libraries

3. I downloaded esp/arduino-master.zip file and found an EEPROM folder which contains this method: EEPROM.commit() -- a method that is not seen in the EEPROM folder of Step-1.

4. In the following ESP8266 sketch if I include or not the EEPROM.commit() method, the sketch us compiled, uploaded, executed, and gives the expected result.

#include<EEPROM.h>

int adr = 0x0000;
void setup()
{
  Serial.begin(115200);
  Serial.println();

EEPROM.begin(512);
  double x1 = -1.156012116E-06;
  //-----------------------------
  EEPROM.put(adr, x1);
  //EEPROM.commit();
  //------------------//EEPROM.end();
  double y1;
  EEPROM.get(adr, y1);
  Serial.println(y1, 15); //shows: -0.001156012116000 ==> -1.156012116E-03 
}

void loop()
{

}




Now, is it reasonable to conclude that the EEPROMs of both ESP8266 (not ESP32) and AVR use the same EEPROM Library of Step-1?

all wrong
you skipped some comments in this thread

No, the ESP8266 does not have an EEPROM. EEPROM is emulated on the ESP8266 and ESP32.

Take delay().

When delay() is called from an Uno it runs blocking code.

When delay() is called from an ESP32, delay() ends up being a wrapper for vTaskDelay(), which is (part of the ESP32's OS, freeRTOS) non blocking code.

GolamMostafa:
3. I downloaded esp/arduino-master.zip file and found an EEPROM folder which contains this method: EEPROM.commit() -- a method that is not seen in the EEPROM folder of Step-1.

That should have been a clue for you right there. Try putting "EEPROM.commit()" into a sketch and compile for an Uno board. Does it compile? Now compile for an ESP8266-based board. Does it compile?

The answers to the above will be "no" and "yes" respectively. Obviously, different EEPROM.h files are being pulled in dependent upon the board type setting -- just as you have been told above in this thread.

gfvalvo:
The answers to the above will be "no" and "yes" respectively. Obviously, different EEPROM.h files are being pulled in dependent upon the board type setting -- just as you have been told above in this thread.

Your proposition has been experimentally verified and stands valid. Is it possible to know the location (folder) that contains the ESP8266 specific EEPROM folder?

Thanks with +1k.

GolamMostafa:
1. I have been interested to know if the EEPROM of ESP8266 (not ESP32) and the EEPROM of ATmega328P do use the same EEPROM Library which is located in the following path of my PC:

C:\Program Files(x86)\Arduino\hardware\arduino\libraries\EEPROM

Please double check that path. It doesn't make sense. C:\Program Files(x86)\Arduino\hardware\arduino\avr\libraries\EEPROM would make sense for the ATmega328P.

And the answer is no. I think I have already made that clear in my previous replies.

GolamMostafa:
2. In my PC, the following are also the paths where various libraries are found/got included; but, I have not found any EEPROM folder in any path except that one of Step-1.

C:\Users\siam\Documents\Arduino\libraries
C:\Program Files(x86)\Arduino\libraries

It's good you didn't find it in either of those locations. As I already explained, the EEPROM library is architecture specific, so you need a different version of the library bundled with each core. Those paths are where you would have the non-bundled libraries, that are available no matter which board you are compiling for.

Assuming you did the normal thing and installed the ESP8266 core via Boards Manager, you should find the ESP8266 version of the EEPROM library at:
C:\Users\siam\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.2\libraries\EEPROM
Note that the AppData folder is a system folder and so is hidden by Windows Explorer by default. You will need to change your preferences to show system folders. If you did a manual installation of the ESP8266 core then you should know where it is located at.

GolamMostafa:
I downloaded esp/arduino-master.zip file

What is this esp/arduino-master.zip thing? That's not even a valid file name. Do you mean arduino-esp32-master.zip?

pert:
What is this esp/arduino-master.zip thing? That's not even a valid file name. Do you mean arduino-esp32-master.zip?

Per, the esp8266 arduino boards package github repo is called Arduino

(it confuses my sometimes why I have a repo called Arduino :slight_smile: )

Yes, I suspect that might be it, but that doesn't explain the "esp/" part and I have learned the hard way all too often that it can be harmful to try to provide support based on assumptions.

Juraj:
(it confuses my sometimes why I have a repo called Arduino :slight_smile: )

Same here, especially since I will just as often have one of that name from the arduino/Arduino repository. I think the historical cause was that the ESP8266 project originally started as a fork of the full Arduino IDE with ESP8266 support added in. Luckily, they soon came to their senses (or maybe some necessary support mechanism was added to the IDE) and pared the project badk to just being the hardware package alone.

pert:
Assuming you did the normal thing and installed the ESP8266 core via Boards Manager, you should find the ESP8266 version of the EEPROM library at:
C:\Users\siam\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.2\libraries\EEPROM

There is no folder/subfolder named AppData\local\Arduino15...... in my PC.

I have found the EEPROM.h file containing commit() method in the following paths of my PC:
C:\Users\siam\Downloads\Arduino-master\Arduino-master\libraries\EEPROM\EEPROM.h
C:\Users\siam\Downloads\Arduino-master\Arduino-master\tests\host\common\EEPROM.h