Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FS.h"
- void setup()
- {
- // SPIFFS.format();
- Serial.begin(115200);
- bool result = SPIFFS.begin(); // always use this to "mount" the filesystem
- Serial.println("SPIFFS opened: " + result);
- File f = SPIFFS.open("/g.txt", "r"); // this opens the file "f.txt" in read-mode
- if (!f)
- {
- Serial.println("File doesn't exist yet. Creating it");
- File f = SPIFFS.open("/g.txt", "w"); // open the file in write mode
- if (!f)
- {
- Serial.println("file creation failed");
- }
- f.println("ssid=abc"); // now write two lines in key/value style with end-of-line characters
- f.println("password=123455secret");
- }
- else
- {
- while (f.available()) // we could open the file
- {
- String line = f.readStringUntil('\n'); //Lets read line by line from the file
- Serial.println(line);
- }
- }
- f.close();
- }
- //------------------------------------
- void loop() {
- // nothing to do for now, this is just a simple test
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement