Table of Contents

LittleFS is now integrated into Arduino ESP32 Core v2, making it easier to store files on the ESP32’s Flash memory. To upload files to LittleFS, follow these steps:

** Step 1: Install the ESP32 LittleFS Data Upload Plugin**

  1. Download the ESP32 LittleFS Plugin:
  1. Extract and Install the Plugin:
  • Locate the Arduino IDE 2.0 Sketchbook folder:
  • Open Arduino IDE 2.0 → Go to File → Preferences
  • Check the “Sketchbook location” path.
  • Extract the ZIP and move the ESP32FS folder into:
[Sketchbook Folder]/tools/
  • After moving the folder, restart Arduino IDE 2.0.

Step 2: Prepare Your Files for Upload

  1. Create a data/ folder inside your sketch directory:
  • Navigate to your sketch folder.
  • Create a new folder named data.
  1. Add files to be uploaded (e.g., .txt, .html, .json, .jpg).
  • Example: If your sketch is named LittleFS_Test.ino, the structure should look like:
LittleFS_Test/
├── LittleFS_Test.ino
├── data/
│   ├── test.txt
│   ├── config.json
│   ├── index.html

Step 3: Upload Files to ESP32’s LittleFS

  1. Open Arduino IDE 2.0.
  2. Select Your ESP32 Board & Port.
  • Go to Tools → Board and select your ESP32 model.
  • Select the correct COM Port.
  1. Open the “ESP32 Sketch Data Upload” Tool.
  • Click on Tools → ESP32 Data Upload.
  • The plugin will format and upload the data/ folder contents to ESP32’s Flash memory.
  • Wait until the upload completes.

tep 4: Verify the Upload

To check if the files were successfully uploaded, use this code:

#include "FS.h"
#include "LittleFS.h"

void setup() {
    Serial.begin(115200);

    if (!LittleFS.begin()) {
        Serial.println("LittleFS Mount Failed!");
        return;
    }

    File file = LittleFS.open("/test.txt", "r");
    if (!file) {
        Serial.println("Failed to open file!");
        return;
    }

    Serial.println("File Content:");
    while (file.available()) {
        Serial.write(file.read());
    }
    file.close();
}

void loop() {
}
  1. Upload the sketch to ESP32.
  2. Open Serial Monitor (Baud rate: 115200).
  3. If successful, the contents of test.txt should be displayed.

Done! You Have Successfully Uploaded Files to LittleFS!

Now you can use these files in your ESP32 projects, such as serving web pages, storing configuration settings, or logging data.

Categorized in:

Storage,

Tagged in: