A ESP8266 board typically contains a 1MB, 4MB, or 16MB external flash chip which is connected to the ESP8266 via the SPI bus. A portion of this flash memory is used as a file system call SPIFFS (SPI Flash File System) and is separate storage from your application sketch storage.
Here you can stores files independent of your Sketch code. Typical usage of the file system include:
- Application configuration: Usually it is not a good idea to hardcode device or environment specific configuration as your application will be less portable. It is better to store these in a configuration file.
- Store security certificates: Most cloud based IOT service require communication over a secure connection and recommend that each device be given a unique certificate to enable fine-grained management. These certificates can be stored on the file system rather than in the device application code.
- Store simple HTML pages and images.
To upload files from the Arduino IDE to your ESP8266 you need to first install the ESP8266FS tool plug-in to Arduino. This will add the 'ESP8266 Sketch Data Upload' option to the Tools menu. Files that you want uploaded should be stored in a 'data' sub-folder in your Sketch folder and the full contents of the data folder are uploaded when this plug-in is selected. Use Ctrl+K to show your current sketch folder location and add a 'data' sub-folder.
The size of the space reserved for the file system on the device is specified by setting in Tools > Flash Size: xxxxx . With my ESP8266 boards I have the option of 1M or 3M SPIFFS. Note that if you change the SPIFFS size you will need to reload both your sketch and data contents to the device.
To use the file system from your application you need to include 'FS.h' in your sketch. A good overview of the library can be found in the ESP8266 Arduino Core documentation.
No comments:
Post a Comment