EEPROM reading - writing string[SOLVED]!

Hello everyone!I'm trying to learn but i found enough difficulties about this board.Especially i 've got difficulties because i can't debug my code.
Could you help me for something?How can i write a string into the eeprom and after that how can i read it from memory???

Can you propose me any good website or book to make a start??

Thanks a lot!

Use EEPROM one byte at a time, like Serial.read().

Thanks for your reply!Be the way have you got anyone an example which can helps someone to store string char by char ( each byte per time ).

That will helps my job a lot !

Thanks

I want to write 300 characters into eeprom.In order to do something like that should i follow something like that??

String inputString = "";
int cbytes = 0;
char inChar;
void writeEEPROM(){
  if(Serial.available()) {
      c = (char)Serial.read();
      EEPROM.write( cbytes++,(byte)inChar );
        
      if( c== '\0' ) 
        Serial.print("Success");   
  }
}

The read process, if i want to took eeprom's data back??

void __read_EEPROM( )  {
  int _addrByte = 0;
  String str;
  int value;
  while( _addrByte++ != 300 )  {
    value = EEPROM.read( _addrByte );
     str += (char)(value);
    _addrByte++;  
  }
  Serial.print(str);
}

In terminal i take some results but my data are not return in the correct order, just i've send them....

Thanks!

When you are reading back from EEPROM you are incrementing the address twice:

void __read_EEPROM( )  {
  int _addrByte = 0;
  String str;
  int value;
  while( _addrByte++ != 300 )  {             //// HERE
    value = EEPROM.read( _addrByte );
     str += (char)(value);
    _addrByte++;                                 ///// And HERE
  }
  Serial.print(str);
}

Take the ++ off the first one. You may also want to add: if (value == 0) break; before str += (char)(value);. That way you won't put all 300 characters into str even when the string is only 20 characters long.

I've just seen it!
My mistake i'm sorry!

Thank you very much!

sirus:
I've just seen it!
My mistake i'm sorry!

Thank you very much!

that type is the c variable? You could send the sketch?

So Sirus has his anser and it is no more interesting for him to respond to your request, Venado_bike.

That´s h ow life is today :frowning:

Hello everyone.
i trying to save String data type in eeprom but i cant do it!
can you guide me . thanks alot.

magickiyan:
Hello everyone.
i trying to save String data type in eeprom but i cant do it!
can you guide me . thanks alot.

You have some code? You forgot to post it, or explain what the problem is.