SOLVED EEPROM put get problems uno vs mega adk

hi there;

#include<EEPROM.h>

struct StartObject {
  float floatValue;
  int intValue;
  char msg[5];
} so;

void setup() {
  Serial.begin(115200);
  StartObject so;
  so.floatValue = 11.55;
  so.intValue = 1457;
  String msg = "NONE";
  strncpy(so.msg, msg.c_str(), sizeof(so.msg));

  EEPROM.put(0, so);
  EEPROM.get(0, so);

  Serial.println(so.intValue);
  Serial.println(so.floatValue);
  Serial.println(so.msg);
}

void loop() {

}

for a first run I comment EEPROM.get(0, so);( just putting data to EEPROM)
output is
1457
11.55
NONE

for a second run I commnet
// so.floatValue = 11.55;
// so.intValue = 1457;
// String msg = “NONE”;
// strncpy(so.msg, msg.c_str(), sizeof(so.msg));
//
// EEPROM.put(0, so);
and uncomment EEPROM.get(0, so);

I was expecting same output, but my output was this:
1457
11.55
NOÎ1457
11.55
NONE

Iam using arduino mega adk rev3

I did same sketch for uno and it works
is it my mega wrong or mega needs another approach?

thx

I put delay(30) beforeEEPROM.get(0, so); and it works :slight_smile: