The string sorage

Hi
I want ti storage a long String in EEPROM
These strings are each for a UID, and a card may be added or subtracted to this set, but every time this long string needs to be stored, does changing a single string in this array overwrite the entire set? Thank you for your guidance

#include <EEPROM.h>
String m[2] = { "937744F6", "F3FBBFFC" };
int eeAddress = 0;

void setup() {

  EEPROM.put(eeAddress, m);
  Serial.begin(9600);
  EEPROM.get(eeAddress, m);

}

void loop() {
  /* Empty loop */
}

The first question you should be asking is whether it is possible to save a String to EEPROM using the put() function and load it back using the get() function

A String is not a variable it is an object of the String library so the answer is no

You could use an array of C style strings (a zero terminated array of chars) instead.

The put() function only writes to EEPROM where the location being written to has changed so changing one element of the array and writing the whole array again does not cause data to be written to every EEPROM location used by teh array

2 Likes

it seems your UIDs are actually 32 bits data... just use

uint32_t myUIDs[] = {0x937744F6, 0xF3FBBFFC};

then it's easy to use put and get to manage the data in EEPROM.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.