More than one EEPROM instance

Hi all.
I am using Arduino IDE and ESP32.
Is it possible to define more than one EEPROM instances.

Like:
#define dogs EEPROM_1
#define cats EEPROM_2

dogs.begin(EEPROM_SIZE);
cats.begin(EEPROM_SIZE);

dogs.writeByte(location,breed);
cats.writeByte(location,breed);

so that i can independent storage.

Regards

EEPROM emulation is deprecated on the ESP32.
Use Preferences instead.

https://espressif-docs.readthedocs-hosted.com/projects/arduino-esp32/en/latest/api/preferences.html

Hi

Thank you for the info.
However I am now half way in my programming.
I prefer to continue with EEPROM.

Any idea about my question?
Regards

What happened when you tried?

Remember EEPROM on the ESP32 has been deprecated. It has been deprecated for 2 ESP32 core updates. You may find that the API may be now incompatible with EEPROM at some point, and you may run into issues.

yes, but as you are just half the way through, I would recommend that you use preferences and not flogging a dead horse.

Hi.
I had a go at the documentation, and some examples.
I found them a little confusing.
For example, take look at the code below.
It is very simple and easy to understand.

#EEPROM_SIZE 20
EEPROM.begin(EEPROM_SIZE);
void save_mydata()
{
   
  for (int address = 0; address < 12; address++)
  {
      EEPROM.writeByte(address, someData );
   }
}

I was not able to convert it to 'Preferences'.
Maybe because the terminology does not reflect the task.
But, definitely, i lack the experience in C++.
I do accept any help though.

Regards

all your lines above are needed to do a simple

  #include <Preferences.h>
  preferences.begin("my-app", false);
  preferences.putUInt("meaningfulVariableName", someData);

the example "Preferences / StartCounter" in the IDE is a very short example how to "write" (put) and "read" (get) a variable from your preference storage.

You should really give it a try.

if you want to provide a short compileable example with meaningful variable names, one could give you an example with preferences.

But honestly - I don't think you will need that - start with the example "Preferences / StartCounter" and the documentation and you will get lucky.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.