Hi Sara,
I have been working with SPIFFS for the last few months and it seem to work just fine. unfortunately, today it is not writing to file anymore. wonder why. please refer my code below. kind help is much appreciated.
<write part>
if(user1 > 0){
//File file = SPIFFS.open(“/user1.txt”, “w”); //same problem
File file = SPIFFS.open(“/user1.txt”, FILE_WRITE);
if(!file){
SerialMon.println(“Failed to open user1.text”);
}else {
SerialMon.printf(“Printing inside SPIFF %lld\n”, user1); // cek to see if program enters here!
file.print(“user1: “);
file.print(user1);
}
file.close();
user1 = 0;
}
<read part>
File file = SPIFFS.open(“user1.txt”, “r”);
String s = “”;
while (file.available()){
char c = file.read();
SerialMon.print(c);
s += c;
SerialMon.print(s);
}
file.close();
SerialMon.println(s);