I'm using an SD card module with ESP32. My plan is to store configurations such as SSID and passwords.
I tried the function with a text file which contains the text "Hello" and for Serial.write(file.read());
it prints exactly "Hello". But, Serial.print(file.read());
returns 72101108108111. What kind of data type returns read()
? I need to convert it into string.
void readFile(fs::FS &fs, const char * path){
Serial.printf("Reading file: %s\n", path);
File file = fs.open(path);
if(!file){
Serial.println("Failed to open file for reading");
return;
}
Serial.print("Read from file: ");
while(file.available()){
//Serial.write(file.read());
Serial.print(file.read());
}
file.close();
}