title: Arduino EEPROM getting corrupt values
body: <p>I'm using Arduino Uno to save several variables into the EEPROM. My solution to this is to create a custom struct in which to store all the variables needed then use EEPROM.put to store them into the built-in EEPROM.</p>
  
  <p>My problem arises not when putting data, but when getting data. Whenever I would change something in my code and/or use the Arduino in a short amount of time, the data stored in the EEPROM gets corrupted.</p>
  
  <p>I check the data through Serial.println() function. From time to time the String data get corrupted but not the other data types as far as I can remember. Maybe an issue with String data?</p>
  
  <pre><code>struct EEPROMDATA
  {
      String customMessage, emergencyMessage;
      String emergencyContact[3];
      String ownerContact;
      String idleMessage;
      int travelThreshold;
      int idleThreshold;
      char password[6];
      location locationList[3];
  };
  
  EEPROMDATA eepromstruct;
  
  void loadReset() 
  {
      EEPROM.get(100, eepromstruct);
  }
  
  void saveReset()
  {
      EEPROM.put(100, eepromstruct);
  }
  </code></pre>
  
  <p>These are the functions I use to save (put) and load (get) the data from the EEPROM. I've read somewhere to avoid writing data at the 0th address that's why the address is set to 100.</p>
  
  <p>Do remember that this is not a writing to EEPROM issue as my program currently doesn't have any references to EEPROM.put nor to saveReset(). Somehow during the course of the program the EEPROM data gets corrupted. I don't know if this is a hardware or a software problem.</p>
  
  <p>EDIT: I forgot to note that when troubleshooting this, whenever a corruption occurs, I re-initialize then save the data in the EEPROM again. After that it works fine for a short while (turning on/off continuously then testing the data, resetting the device, etc.) until it corrupts again.</p>