Reading Sensor Log in TXT File

Hi everyone,

I'm writing a sensor log in a TXT file in a SD card. So, I write 1, 2, 3 in a TXT File... So far, so good 8)

But, I need to read this log and store into a int... Here is my problem... The value stored is only the last character. If has a 15 stored in file, the int returns 5.

int ior() {

int data;
  
myFile = SD.open("approved.txt");
  
  if (myFile){
     
    while (myfile.available()){ 
        data = myFile.read();
    }
    
  }
  
  return (data);
}

Somebody could help me?

Thanks in advance...

The value stored is only the last character.

No. The value that YOU store is always the last value read. You could do otherwise, using an array.