ESP8266 File System
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "FS.h" | |
void setup() { | |
SPIFFS.begin(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dir dir = SPIFFS.openDir("/"); | |
while (dir.next()) | |
Serial.printf("FS File: %s\n", dir.fileName().c_str()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a simple homepage | |
webServer.serveStatic("/", SPIFFS, "/index.html"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> | |
#include <ESP8266WebServer.h> | |
#include "FS.h" | |
ESP8266WebServer webServer(80); | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(115200); | |
//The SSID must be >8 characters and <64 characters | |
//I'm adding the chip ID onto the end to get a unique (ish) name | |
String ssid = "ESP8266 " + String(ESP.getChipId(), HEX); | |
//The password must be <64 characters and can be left blank for no password | |
String pass = "password"; | |
Serial.printf("WiFiSSID: '%s'\n", ssid.c_str()); | |
Serial.printf("Password: '%s'\n", pass.c_str()); | |
SPIFFS.begin(); | |
Dir dir = SPIFFS.openDir("/"); | |
while (dir.next()) | |
Serial.printf("FS File: %s\n", dir.fileName().c_str()); | |
WiFi.mode(WIFI_AP); | |
WiFi.softAP(ssid.c_str(), pass.c_str()); | |
// Create a simple homepage | |
webServer.serveStatic("/", SPIFFS, "/index.html"); | |
webServer.begin(); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
webServer.handleClient(); | |
} |
Now when you open the Arduino IDE there should be an additional option in the 'Tools' menu system. ESP8266 Sketch Data Upload. If you create a folder called 'Data' next to your arduino sketch, then the tool will convert any files in that folder, into an image and send them to the file system on the device.