22 ESP32 eeprom_class example with EEPROM library
33
44 This simple example demonstrates using EEPROM library to store different data in
5- ESP32 Flash memory in a multiple user-defined EEPROM partition (0x1000 or 4KB max size or less) .
5+ ESP32 Flash memory in a multiple user-defined EEPROM class objects .
66
7- Install 'ESP32 Partiton Manager' ONCE from https://github.com/francis94c/ESP32Partitions
8- And generate different partitions with 'partition_name'
9- Usage: EEPROMClass ANY_OBJECT_NAME("partition_name", size);
10-
11- Generated partition that would work perfectly with this example
12- #Name, Type, SubType, Offset, Size, Flags
13- nvs, data, nvs, 0x9000, 0x5000,
14- otadata, data, ota, 0xe000, 0x2000,
15- app0, app, ota_0, 0x10000, 0x140000,
16- app1, app, ota_1, 0x150000, 0x140000,
17- eeprom0, data, 0x99, 0x290000, 0x1000,
18- eeprom1, data, 0x9a, 0x291000, 0x500,
19- eeprom2, data, 0x9b, 0x292000, 0x100,
20- spiffs, data, spiffs, 0x293000, 0x16d000,
21-
227 Created for arduino-esp32 on 25 Dec, 2017
238 by Elochukwu Ifediora (fedy0)
9+ converted to nvs by lbernstone - 06/22/2019
2410*/
2511
2612#include " EEPROM.h"
2713
28- // Instantiate eeprom objects with parameter/argument names and size same as in the partition table
14+ // Instantiate eeprom objects with parameter/argument names and sizes
2915EEPROMClass NAMES (" eeprom0" , 0x500 );
3016EEPROMClass HEIGHT (" eeprom1" , 0x200 );
3117EEPROMClass AGE (" eeprom2" , 0x100 );
3218
3319void setup () {
34- // put your setup code here, to run once:
3520 Serial.begin (115200 );
3621 Serial.println (" Testing EEPROMClass\n " );
3722 if (!NAMES.begin (NAMES.length ())) {
@@ -57,7 +42,7 @@ void setup() {
5742 double height = 5.8 ;
5843 uint32_t age = 47 ;
5944
60- // Write: Variables ---> EEPROM partitions
45+ // Write: Variables ---> EEPROM stores
6146 NAMES.put (0 , name);
6247 HEIGHT.put (0 , height);
6348 AGE.put (0 , age);
@@ -75,7 +60,7 @@ void setup() {
7560 Serial.print (" age: " ); Serial.println (age);
7661 Serial.println (" ------------------------------------\n " );
7762
78- // Read: Variables <--- EEPROM partitions
63+ // Read: Variables <--- EEPROM stores
7964 NAMES.get (0 , name);
8065 HEIGHT.get (0 , height);
8166 AGE.get (0 , age);
@@ -87,6 +72,5 @@ void setup() {
8772}
8873
8974void loop () {
90- // put your main code here, to run repeatedly:
91-
75+ delay (0xFFFFFFFF );
9276}
0 commit comments