So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By raytravel
#88264 In the following sketch I am trying to make write/read from spiffs a subroutine.
But I keep getting errors
ssidx is a string/variable I want to save in filex.txt then later read back and save to sdatax string variable
I want to save/return maybe 10 different saved different variables.

Code: Select all#include <FS.h>
String sdatax ="";
String ssidx="";
void setup(){
 bool success = SPIFFS.begin();
 if (!success){Serial.println("Error mountingthe file system"); return;}
void read2_spiffs(){
 File file2 ="/filex.txt", "r");
 if (!file2){ Serial.println("failed to open file for reading");return;}
 sdatax = file2.readString();
void write2_spiffs(){
 File file ="/filex.txt", "w");
 if (!file) {Serial.println("Error opening file for writing");return;}
 int bytesWritten = file.print(ssidx);
 if (bytesWritten ==0){Serial.println("File write failed");return;}
 void loop()