Save strings in EEPROM

Hi,
I want to save some strings in EEPROM, which have an uncertain length and am not sure how to do this. Does anyone know a way of doing this?

Thankyou in advance...
Conor :slight_smile:

Decide how many strings you think you want to save, and store a simple index array at the start of EEPROM to point to the strings.

Strings are terminated with 0. You can have the strings one after the other, no matter their length.

You can have the strings one after the other, no matter their length

But you still need to know where they start..

if I try to save strings in EEPROM I get an error message... :frowning:
How would I go about saving them as an array?

:slight_smile:

What is the C code you use to try to save the strings?

What is the error message?

You need a function like this, whereby:-

newWriteLocation is the start position in eeprom
byteCount is the length of yourString

EEPROM.write(newWriteLocation+byteCount, int(yourString[byteCount]));

Once you start storing data in eeprom, you might need additional routines to:-

search records
delete records
add new records
determine number of free blocks available

And each of those routines need supporting routines, like you might want to use 2 large arrays, both the same size as eeprom, that you manipulate before writing the entire array back to eeprom, especially if your trying to delete a string and reorder the eeprom to make more efficient use of the available space after the strings been deleted.

It's a real can of worms unless you can find code in the playground that already does what your wanting.

conanim, you may want to take a look at my recent post here:

A bit of explanation, a bit of code...