• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

SPIFFS not writing to file

Q&A Forum › SPIFFS not writing to file
0 Vote Up Vote Down
NUR AZLIN AIRUL AZLIN MOHAMED ZOHDI asked 4 years ago

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);

Question Tags: SPIFFS
2 Answers
0 Vote Up Vote Down
NUR AZLIN AIRUL AZLIN MOHAMED ZOHDI answered 4 years ago

Hi Sara,
Never mind, I found the mistake only after posting this here. Sorry about that.

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Great!
I’ll close this issue.
If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.