Skip to content
Prev Previous commit
updated and annotated example
  • Loading branch information
fedy0 committed Feb 2, 2018
commit be8b7565a43c79136e5c7a745cf30b99eccb2780
25 changes: 18 additions & 7 deletions libraries/EEPROM/examples/eeprom_class/eeprom_class.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,33 @@
ESP32 eeprom_class example with EEPROM library

This simple example demonstrates using EEPROM library to store different data in
ESP32 Flash memory in a multiple user-defined EEPROM partition (0x1000 or 4KB max size).
ESP32 Flash memory in a multiple user-defined EEPROM partition (0x1000 or 4KB max size or less).

Install 'ESP32 Partiton Manager' ONCE from https://github.com/francis94c/ESP32Partitions
And create different partitions with 'partition_name'
Usage: EEPROMClass ANY_OBJECT_NAME("partition_name");
And generate different partitions with 'partition_name'
Usage: EEPROMClass ANY_OBJECT_NAME("partition_name", size);

Generated partition that would work perfectly with this example
#Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x140000,
app1, app, ota_1, 0x150000, 0x140000,
eeprom0, data, 0x99, 0x290000, 0x1000,
eeprom1, data, 0x9a, 0x291000, 0x500,
eeprom2, data, 0x9b, 0x292000, 0x100,
spiffs, data, spiffs, 0x293000, 0x16d000,

Created for arduino-esp32 on 25 Dec, 2017
by Elochukwu Ifediora (fedy0)
*/

#include "EEPROM.h"

// Instantiate eeprom objects with parameter/argument names same as in the partition table
EEPROMClass NAMES("eeprom0");
EEPROMClass HEIGHT("eeprom1");
EEPROMClass AGE("eeprom2");
// Instantiate eeprom objects with parameter/argument names and size same as in the partition table
EEPROMClass NAMES("eeprom0", 0x1000);
EEPROMClass HEIGHT("eeprom1", 0x500);
EEPROMClass AGE("eeprom2", 0x100);

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