Problem reading written Data

Hallo everyone,

i just got my Ethernetshield and i`m trying to store some Data in an MicroSD card and read it back.

My Writing function is:

createFile("VERSION.NUM", "Versionsnummer") 

void createFile(char* dateiname , String dateiinhalt) {
  int bytewritten = 0;
  // Erstellt eine Datei mit dem übergebenem Inhalt
   myFile = SD.open(dateiname , FILE_WRITE);
   bytewritten = myFile.print(dateiinhalt);
   myFile.close();
}

The file is created on the card. now i try to read the just written data back

readfromFile("VERSION.NUM");

void readfromFile(char* dateiname) {
  String incommingData = "";
  myFile = SD.open(dateiname , FILE_READ);
  while (myFile.available()) {
      Serial.println(myFile.read());
  }
  myFile.close();
}

In the Serial Monotor i get:

86
101
114
115
105
111
110
115
110
117
109
109
101
114

I guess these are the bytes wich were read, but how do i get a "humanreadable" String of this to use the stored data in the programm?

CL

Try this instead:

  while (myFile.available()) {
      Serial.write(myFile.read());
  }

Serial.println() converts the integer return to a number. Serial.write() does not.

Ah ok thank you,

but now i got another Problem. After the Data is now correctly shown on the screen i want to get it into some form, that i can use in the programm. Trying to make a string leaves an if Check going false? An Idea?

Trying to make a string leaves an if Check going false? An Idea?

I don't understand this statement. I don't see any attempt at codding this, either, though.

Hi everyone

got the problem solved, i need to use an internal buffer to read from the file and put this buffer together to a char so i can use it...

Tnx for the help here :smiley: