Hello,
I am trying to run this simple program on Arduino IDE in linux. But I am not sure why nothing is been written to my file. Can anyone please help me solve this issue?
I created newfile using the command on ubuntu and then renamed it to "test" using mv. My file is stored in sketch_oct27a folder, I also get "File was written" on the serial monitor after the program is uploaded but my file is empty.
#include "SPIFFS.h"
void setup() {
Serial.begin(115200);
if (!SPIFFS.begin(true)) {
Serial.println("An Error has occurred while mounting SPIFFS");
return;
}
File file = SPIFFS.open("/sketch_oct27a/test.txt", FILE_WRITE);
if (!file) {
Serial.println("There was an error opening the file for writing");
return;
}
if (file.print("TEST SPIFFS........")) {
Serial.println("File was written");
} else {
Serial.println("File write failed");
}
file.close();
}
void loop() {}