• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ESP32 EEPROM problems

Wp100

Well-Known Member
Hi,

Porting an existing Arduino project over to the ESP32 WRoom32 board.

If I run just this example EEPROM code on the ESP32 it returns the data correctly.

However when I tried running my original EEPROM code in the project code it does not work returning values of 0.

So I added the test code below, as the first lines of code in the SetUp section of my project code, but it also would not run correctly , just returning 0 and 0

The project is using the following libraries so wonder if there is some form of contention ?

Whats not quiet clear from the info on the ESP32s EEPROM is does the EEPROM commit() have to be run after each EEPROM Write or just after a block of Writes ?

There seems a lot of quiet complex info on the web about varoius way of using the ESP32s Flash memeory as EEPROM; is this simple method below stable enough for saving a few bytes each hour ?

Project Libraries -
Code:
#include <Wire.h>

#include <OneWire.h>

#include <DallasTemperature.h>

#include <EEPROM.h

#include "Sodaq_DS3231.h"

#include "Adafruit-GFX-Library-master\Adafruit_GFX.h"

#include "Adafruit_ILI9341.h"

#include "SPI.h"                   

#include "XPT2046_Touchscreen.h"

EEprom test code, ok when run independatly, but fails when run in the project code -

Code:
// include library to read and write from flash memory
#include <EEPROM.h>

// define the number of bytes you want to access
#define EEPROM_SIZE 60

byte  DataE = 35;
byte  DataD = 44;


void setup() {
    Serial.begin(115200);
    // initialize EEPROM with predefined size
    EEPROM.begin(EEPROM_SIZE);
}


void loop() {
    EEPROM.write(0, DataE);
    EEPROM.commit();

    EEPROM.write(1, DataD);
    EEPROM.commit()

    delay (1000);

    byte TEST = EEPROM.read(0);
    byte TEST1 = EEPROM.read(1);

    Serial.println (TEST,DEC);
    Serial.println (TEST1,DEC);
 
     delay (100000);

}
 

Latest threads

EE World Online Articles

Loading
Top