How to Upload Sketch to Esp8266 Nodemcu

The ESP8266 contains a Serial Peripheral Interface Flash File System (SPIFFS). SPIFFS is a lightweight filesystem created for microcontrollers with a flash chip. This article shows how to easily upload files to the ESP8266 filesystem using a plugin for Arduino IDE.

Install ESP8266 Filesystem Uploader in Arduino IDE

Note: if you have an ESP32 lath, read Install ESP32 Filesystem Uploader in Arduino IDE.

Introducing SPIFFS

SPIFFS lets you access the flash chip retention like you would do in a normal filesystem in your reckoner, but simpler and more limited. Y'all can read, write, close, and delete files. SPIFFS doesn't support directories, so everything is saved on a apartment structure.

Using SPIFFS with the ESP8266 board is peculiarly useful to:

  • Create configuration files with settings;
  • Save information permanently;
  • Create files to save pocket-sized amounts of data instead of using a microSD card;
  • Salvage HTML and CSS files to build a web server;
  • Save images, figures and icons;
  • And much more.

In most of our web server projects, we've written the HTML code for the web server equally a String directly on the Arduino sketch. With SPIFFS, you can write the HTML and CSS in separated files and salvage them on the ESP8266 filesystem.

Installing the Arduino ESP8266 Filesystem Uploader

You lot tin can create, save and write files to the ESP8266 filesystem by writing the code yourself in Arduino IDE. This is not very useful, because you'd have to type the content of your files in the Arduino sketch.

Fortunately, there is a plugin for the Arduino IDE that allows you to upload files directly to the ESP8266 filesystem from a folder in your computer. This makes it actually easy and simple to work with files. Let's install information technology.

First, make certain you have the latest Arduino IDE installed, and you have the ESP8266 improver for the Arduino IDE. If you don't, follow the next tutorial to install the add-on:

  • Windows, Mac and Linux instructions – Installing the ESP8266 Lath in Arduino IDE

Follow the next steps to install the filesystem uploader:

1) Go to the releases page and click the ESP8266FS-Ten.naught file to download.

Download ESP8266 SPIFFS Filesystem fs for Arduino IDE

2) Get to the Arduino IDE directory, and open the Tools binder.

Arduino IDE Tools to Install ESP8266 SPIFFS Filesystem fs

iii) Unzip the downloaded .nil folder to the Tools folder. You should take a similar binder structure:

<home_dir>/Arduino-<version>/tools/ESP8266FS/tool/esp8266fs.jar        
Arduino IDE Tools to Install ESP8266 SPIFFS Filesystem fs

iv) Finally, restart your Arduino IDE.

To check if the plugin was successfully installed, open your Arduino IDE and select your ESP8266 board. In the Tools menu check that you lot accept the option "ESP8266 Sketch Data Upload".

ESP8266 Sketch Data Upload Arduino IDE SPIFFS FS Filesystem

Uploading Files using the Filesystem Uploader

To upload files to the ESP8266 filesystem follow the next instructions.

1) Create an Arduino sketch and save it. For sit-in purposes, you tin save an empty sketch.

two) And so, open the sketch binder. Yous can get to Sketch > Show Sketch Folder. The folder where your sketch is saved should open.

Arduino IDE Show Sketch folder to create data folder

three) Inside that folder, create a new folder called data .

ESP8266 Arduino Sketch Example File Filesystem fs SPIFFS

4) Inside the data folder is where you should put the files y'all want to be saved into the ESP8266 filesystem. Every bit an example, create a .txt file with some text called test_example.

ESP8266 Notepad Test Example File Filesystem fs SPIFFS

5) In the Arduino IDE, in the Tools menu, select the desired SPIFFS size (this will depend on the size of your files)

ESP8266 Select SPIFFS FS Filesystem size in Tools menu using Arduino IDE

6) Then, to upload the files, in the Arduino IDE, you just need to become to Tools> ESP8266 Sketch Information Upload.

ESP8266 Sketch Data Upload Arduino IDE SPIFFS FS Filesystem

You should get a similar bulletin on the debugging window. The files were successfully uploaded to the ESP8266 filesystem.

SPIFFS Image Connecting to ESP8266 board

Testing the Uploader

Now, let's just check if the file was actually saved into the ESP8266 filesystem. Simply upload the following code to your ESP8266 board.

          /*********   Rui Santos   Complete project details at https://RandomNerdTutorials.com   *********/  #include "FS.h"   void setup() {   Serial.brainstorm(115200);      if(!SPIFFS.begin()){     Serial.println("An Fault has occurred while mounting SPIFFS");     render;   }      File file = SPIFFS.open up("/test_example.txt", "r");   if(!file){     Serial.println("Failed to open file for reading");     render;   }      Serial.println();   Series.println("File Content:");   while(file.available()){     Serial.write(file.read());   }   file.shut(); }   void loop() {  }                  

View raw code

After uploading, open the Serial Monitor at a baud charge per unit of 115200. Press the ESP8266 "RST" button. It should impress the content of your .txt file on the Serial Monitor.

ESP8266 SPIFFS FS Filesystem Example Arduino IDE Serial Monitor

You've successfully uploaded files to the ESP8266 filesystem using the plugin.

Wrapping Up

Using the filesystem uploader plugin is one of the easiest ways to upload files to the ESP8266 filesystem. You can save HTML and CSS files to build a spider web server, images or small icons, salvage configuration files, etc…

We take a project case in which nosotros build a web server using HTML and CSS files saved on the filesystem. The example is for the ESP32, simply it should be compatible with the ESP8266 with small changes on the lawmaking.

If you like the ESP8266, you may like the post-obit resource:

  • Dwelling house Automation using ESP8266
  • ESP8266 DHT11 Temperature and Humidity Web Server
  • ESP8266 Web Server Control Outputs
  • ESP8266 GPIO Reference Guide
  • More ESP8266 resource

Thanks for reading

coopernoppy1967.blogspot.com

Source: https://randomnerdtutorials.com/install-esp8266-filesystem-uploader-arduino-ide/

0 Response to "How to Upload Sketch to Esp8266 Nodemcu"

Postar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel