load a file in eeprom

:zipper_mouth_face: 'lo there...

i try to load a txt file in my wonderful 24c01 used in i2c way..
what do you suggest me to use for load it into it ? string sequence ? stream ?
i'd look on the library, but i did not see exemple of file's handles.

ever test it ? :fearful: many thanks

i try to load a txt file in my wonderful 24c01 used in i2c way..
what do you suggest me to use for load it into it ? string sequence ? stream ?
i'd look on the library, but i did not see exemple of file's handles.

If your .txt file located in SdCard read the file in chunks(size of chunk must equal to size of EEPROM memory block)
Read/Write Serial EEPROM via I2C for 24c01 interfacing

:zipper_mouth_face: yes i 'd ever test this fritzing beta and it works very nice.. :grin:

but instead of counting basicly, i want to push a little file.txt into it..(size=300 bytes) :.

but instead of counting basicly, i want to push a little file.txt into it..(size=300 bytes)

First Step
Reading a file from Sd Card

void readFile(char* file ,char *fileData)
{
  int16_t  readed;
  File myFile = SD.open(file,FILE_READ);

  if(myFile!=NULL){
    char* buf = (char*) malloc(myFile.size()+1);
    readed = myFile.read(buf,myFile.size());
    buf[readed]='\0';

    myFile.close();
    strcpy(fileData,buf);
    free(buf);
  }
  else
      strcpy(fileData,"Fail to open file");
}

Second step
call this funtion when you want to readfile for e.g file name test.txt

char fileData[300];
readFile("test.txt",fileData)

last step push data from fileData to EEPROM it's on you 8)

One important point intialize the SD (Sd.begin(4)) in setup

but instead of counting basicly, i want to push a little file.txt into it..(size=300 bytes)

What's wrong with counting? It's incredibly simple:

count++;

Read a character, write to EEPROM, increment the address. Repeat until the end of the file is reached.

:astonished: ok i going to see that...sd card libraries gives many idea about this...
thanks very much everyone....
:wink:

PaulS:
Read a character, write to EEPROM, increment the address. Repeat until the end of the file is reached.

Assuming you want to read the content back from EEPROM at some point, you'd need to provide some way to know how long the 'file' was. You might be willing to remember the number of bytes that were written and hard-code that value in the code to read it - it would work, although it isn't an elegant solution.