Esp8266 Spiffs File System Uploading and Reading A File
Posted: Sat May 21, 2016 8:07 am
Esp8266 have a very good file system. But it is hard for newbies.
So i discovered a way to read files From Spiffs Filesystem.
Esp8266 Repo Did not included the Spiffs Upload Tool which is required for making and uploading Files to Esp8266 FileSystem.
To Upload Files to Spiffs (Esp8266 File System) you need esp8266fs.jar Placed like:
Program files/Arduino/tools/ESP8266FS/tool/esp8266fs.jar
Download: https://github.com/esp8266/arduino-esp8266fs-plugin/releases/download/0.2.0/ESP8266FS-0.2.0.zip
Check Updates: https://github.com/esp8266/arduino-esp8266fs-plugin/releases
Next you need to Make New Sketch to test Spiffs:
Now Save your sketch, Go to Sketch Data Folder By Pressing Sketch > Show Sketch Folder
Now add a folder name it "data" without quotes.
add some text files in it or make a new one.
(Keep your Baudrate to Highest 921600 if works)
In Arduino Press Tools > Esp8266 Sketch Data Upload
It should upload Spiff files to your esp8266.
It should take some time.
After it completes, Open Arduino Serial Window and then , Upload code to arduino.
Arduino will automatically switch com port to Serial Display when done.
Check your file Contents and Errors.
You can check This inbuilt Sketch too :
I have Sucessfully Loaded Data from SPIFFS to OLED using i2c port.
See This :
Loading Screen:
Documents on SPIFFS: https://github.com/esp8266/Arduino/blob/master/doc/filesystem.md
Making another post for showing complete code.
So i discovered a way to read files From Spiffs Filesystem.
Esp8266 Repo Did not included the Spiffs Upload Tool which is required for making and uploading Files to Esp8266 FileSystem.
To Upload Files to Spiffs (Esp8266 File System) you need esp8266fs.jar Placed like:
Program files/Arduino/tools/ESP8266FS/tool/esp8266fs.jar
Download: https://github.com/esp8266/arduino-esp8266fs-plugin/releases/download/0.2.0/ESP8266FS-0.2.0.zip
Check Updates: https://github.com/esp8266/arduino-esp8266fs-plugin/releases
Next you need to Make New Sketch to test Spiffs:
Code: Select all
#include"FS.h"
void setup() {
Serial.begin(115200);
bool ok = SPIFFS.begin();
if (ok) {
Serial.println("ok");
boolexist = SPIFFS.exists("/index.html");
if (exist) {
Serial.println("The file exists!");
File f = SPIFFS.open("/index.html", "r");
if (!f) {
Serial.println("Some thing went wrong trying to open the file...");
}
else {
int s = f.size();
Serial.printf("Size=%d\r\n", s);
// USE THIS DATA VARIABLE
String data = f.readString();
Serial.println(data);
f.close();
}
}
else {
Serial.println("No such file found.");
}
}
}
void loop() {
// put your main code here, to run repeatedly:
}
Now Save your sketch, Go to Sketch Data Folder By Pressing Sketch > Show Sketch Folder
Now add a folder name it "data" without quotes.
add some text files in it or make a new one.
(Keep your Baudrate to Highest 921600 if works)
In Arduino Press Tools > Esp8266 Sketch Data Upload
It should upload Spiff files to your esp8266.
It should take some time.
After it completes, Open Arduino Serial Window and then , Upload code to arduino.
Arduino will automatically switch com port to Serial Display when done.
Check your file Contents and Errors.
You can check This inbuilt Sketch too :
I have Sucessfully Loaded Data from SPIFFS to OLED using i2c port.
See This :
Loading Screen:
Documents on SPIFFS: https://github.com/esp8266/Arduino/blob/master/doc/filesystem.md
Making another post for showing complete code.