Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By ajaybnl
#47763 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


Image

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.

Image

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 :

Image



I have Sucessfully Loaded Data from SPIFFS to OLED using i2c port.

See This :
Image

Loading Screen:

Image


Documents on SPIFFS: https://github.com/esp8266/Arduino/blob/master/doc/filesystem.md

Making another post for showing complete code. :D
Last edited by ajaybnl on Sat Jul 23, 2016 3:19 am, edited 1 time in total.
User avatar
By Manti
#49942 [quote="idolpx"]PlatformIO makes it really easy to upload your data as well. I'm really loving this IDE.

It looks awesome, but got one question.

When I upload my html files, it seems that the arrive but when I open them its just jiberish.

For example my index.html looks like this:

âí/1.1 200 OK Content-Type: text/html Content-Length: 872 Connection: close Access-Control-Allow-Origin: * À¨hÝâ–;ÿ?ªªintÀ ,¸îe"‚½þ4Öþ4Ö ªªEœ’ÿ1À¨À¨dPÈa!ÒççÝDPK„3HTTP/1.1 200 OK Content-Type: text/html Content-Length: 872 Connection: close Access-Control-Allow-Origin: * ¸îe"‚½þ4ÖESÿ1ËÀ¨À¨d5Ψ?ÍÈÓÁ ymufcvszqkoppertintÀ ,À¨hëÿíh³ôâh`ýPhwf>ÿ?66

Is it possible to upload the files at once, instead of combining them into a *.bin and flashing them?