I’m working with ESP32s, and trying to get the EEPROM to store data. I’m working direct from the Arduino examples - code below. I’m trying a couple of different boards (AZ-Delivery and a Feather ESP32), but not managing to get anything sensible out of the EEPROM - it generally returns everything as 0. I’ve tried with platform = https://github.com/Jason2866/platform-espressif32.git
, and now I get some numbers, but nothings sensible.
Should EEPROM work here?
Code:
#include "EEPROM.h"
struct MyObject {
float field1;
byte field2;
char name[10];
};
void setup() {
Serial.begin(115200);
delay(1400);
int eeAddress = 5; //Move address to the next byte after float 'f'.
MyObject source = { 3.5f, 65, "Hello!" };
EEPROM.put(eeAddress,source);
MyObject target;
EEPROM.get(eeAddress, target);
Serial.println("Read custom object from EEPROM: ");
Serial.println(target.field1);
Serial.println(target.field2);
Serial.println(target.name);
}
void loop() {
/* Empty loop */
}
Output with platform = https://github.com/Jason2866/platform-espressif32.git
:
Writing custom object to EEPROM:
3.50
65
Hello!
Read custom object from EEPROM:
0.00
140
��?
If I add a EEPROM.commit()
before reading it’s the same.
Using platform = espressif32
, I get:
Writing custom object to EEPROM:
3.50
65
Hello!
Read custom object from EEPROM:
0.00
0
Any ideas?