• 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 1 year 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 1 year 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 1 year 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

  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023
  • [eBook Updated] SMART HOME with RPi, ESP32, and ESP8266 (version 1.1) November 20, 2022

You must be logged in to view this content.

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

Copyright © 2013-2023 · 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.