ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (2024)

In this guide, you’ll learn how to upload files to the ESP32 Filesystem (LittleFS) by using a plugin for Arduino IDE (1.8.X). LittleFS is a lightweight filesystem created for microcontrollers that lets you access the flash memory like you would do in a standard file system on your computer, but simpler and more limited. The plugin we’ll install lets you use three different filesystems: LittleFS, SPIFFS, or FatFS.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (1)

Using Arduino IDE 2? Follow this tutorial instead: Arduino IDE 2: Install ESP32 LittleFS Uploader (Upload Files to the Filesystem)

If you want to use LittleFS with the ESP8266, read: Install ESP8266 NodeMCU LittleFS Filesystem Uploader in Arduino IDE.

Table of Contents

  • Introducing LittleFS
  • Installing the Arduino ESP32 filesystem uploader
    • Windows Instructions
    • Mac OS X Instructions
  • Uploading Files to ESP32 LittleFS using the Filesystem Uploader
  • Testing the ESP32 Filesystem Uploader

Introducing LittleFS

LittleFS is a lightweight filesystem created for microcontrollers that lets you access the flash memory like you would do in a standard file system on your computer, but it’s simpler and more limited. You can read, write, close, and delete files. Using a filesystem with the ESP32 boards is especially useful to:

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

Installing the Arduino ESP32 filesystem uploader

Currently, there is a plugin for the Arduino IDE (version 1.8.X) that allows you to pack and upload files to the SPIFFS, LittleFS, or FatFS filesystem image in the ESP32 filesystem.

Note: in most of our projects we use SPIFFS for the ESP32 filesystem. It’s still compatible with the ESP32, and you can use SPIFFS without any issues. However, currently, many libraries are moving to LittleFS.

The plugin we’ll install is both compatible with SPIFFS and LittleFS. So, it’s an advantage over the older plugin and you can still use SPIFFS.

There are a few advantages of using LittleFS over SPIFFS:

  • LittleFS is optimized for low resource usage and it employs a wear-leveling algorithm that evenly distributes writes across the flash memory, prolonging its lifespan.
  • LittleFS provides faster mount times and file access by utilizing a directory indexing structure.
  • LittleFS minimizes the risk of data corruption during power loss or system failures.
  • LittleFS is under active development.

Windows Instructions

Follow the next steps to install the filesystem uploader if you’re using Windows:

1) Go to the releases page and click the latest esp32fs.zip file to download.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (2)

2) Unzip the downloaded file. You should have a folder called esp32fs with a file called esp32fs.jar inside.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (3)

3) Find your Sketchbook location. In your Arduino IDE, go to File > Preferences and check your Sketchbook location. In my case, it’s in the following path: C:\Users\sarin\Documents\Arduino.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (4)

4) Go to the sketchbook location, and create a tools folder if you don’t have it already (make sure that the Arduino IDE application is closed).

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (5)

5) Inside the tools folder, create another folder called ESP32FS if you haven’t already.

6) Inside the ESP32FS folder, create a folder called tool.

7) Copy the esp32fs.jar file to the tool folder (if you already have an esp32fs.jar file from a previous plugin, delete it and replace it with the new one). So, the directory structure will look like this:

<home_dir>/Arduino/tools/ESP32FS/tool/esp32fs.jar
ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (6)

8) Now, you can open Arduino IDE.

To check if the plugin was successfully installed, open your Arduino IDE and select your ESP32 board. In the Tools menu, check that you have the option “ESP32 Sketch Data Upload“. Click on that option. A window will pop up for you to choose the filesystem you want to use.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (7)

As you can see, you have the option to choose from LittleFS, SPIFFS, or FatFS and you can even have the option to erase flash if needed.

Congratulations! You’ve successfully installed the Filesystem uploader plugin for the ESP32 on the Arduino IDE.

Mac OS X Instructions

Follow the next instructions if you’re using MacOS X.

1) Go to the releases page and click the latest esp32fs.zip file to download.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (8)

2) Unpack the files. You should have a folder called esp32fs with a file called esp32fs.jar inside.

3) Create a folder called tools in /Documents/Arduino/ if you haven’t already.

4) Inside the tools folder create another one called ESP32FS.

5) Inside the ESP32FS folder, create a folder called tool. So, the directory structure will look like this:

<home_dir>/Arduino/tools/ESP32FS/tool/

6) Copy the unpacked esp32fs.jar file to the tool directory (if you already have an esp32fs.jar file from a previous plugin, delete it and replace it with the new one). You should have a similar folder structure.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (9)

7) Now, you can open Arduino IDE.

To check if the plugin was successfully installed, open your Arduino IDE and select your ESP32 board. In the Tools menu, check that you have the option “ESP32 Sketch Data Upload“.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (10)

Click on that option. A window will pop up for you to choose the filesystem you want to use.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (11)

As you can see, you have the option to choose from LittleFS, SPIFFS, or FatFS and you can even have the option to erase flash if needed.

Congratulations! You’ve successfully installed the Filesystem uploader plugin for the ESP32 on the Arduino IDE.

Uploading Files using the Filesystem Uploader

To upload files to the ESP32 LittleFS filesystem follow the next instructions.

1) Create an Arduino sketch and save it. For demonstration purposes, you can save an empty sketch.

2) Then, open the sketch folder. You can go to Sketch > Show Sketch Folder. The folder where your sketch is saved should open.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (12)

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

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (13)

4) Inside the data folder is where you should put the files you want to save into the ESP32 filesystem. As an example, create a .txt file with some text called test_example.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (14)

5) Then, to upload the files, in the Arduino IDE, you just need to go to Tools> ESP32 Sketch Data Upload.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (15)

6. Select the LittleFS option and click OK.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (16)

Make sure the Serial Monitor is closed before uploading the files, otherwise, you’ll get an error related to the Serial communication, and the files won’t upload.

The uploader will overwrite anything you had already saved in the filesystem.

Note: in some ESP32 development boards you need to press the on-board BOOT button for around two seconds to upload the files.

The files were successfully uploaded to the ESP32 filesystem when you see the message “LittleFS Image Uploaded“.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (17)

Testing the Filesystem Uploader Plugin

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

/********* Rui Santos Complete project details at https://RandomNerdTutorials.com/esp32-littlefs-arduino-ide/*********/#include "LittleFS.h" void setup() { Serial.begin(115200); if(!LittleFS.begin()){ Serial.println("An Error has occurred while mounting SPIFFS"); return; } File file = LittleFS.open("/test_example.txt"); if(!file){ Serial.println("Failed to open file for reading"); return; } Serial.println("File Content:"); while(file.available()){ Serial.write(file.read()); } file.close();} void loop() {}

View raw code

After uploading, open the Serial Monitor at a baud rate of 115200. Press the ESP32 “ENABLE/RST” button. It should print the content of your .txt file on the Serial Monitor.

ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (18)

You’ve successfully uploaded files to the ESP32 filesystem using the plugin.

Wrapping Up

In this tutorial, you installed a plugin for the Arduino IDE that allows you to upload files to the ESP32 filesystem. This plugin supports three different filesystems: SPIFFS, LittleFS, and FatFS.

While many libraries and projects are moving to LittleFS, SPIFSS is still used and your previous projects that use SPIFFS should still be working.

Because this new plugin supports both SPIFFS and LittleFS, you should consider installing this one instead of the SPIFFS plugin so that you have more flexibility with the choice of filesystem.

We hope you’ve found this tutorial useful.

Learn more about the ESP32 using our resources:

  • Learn ESP32 with Arduino IDE (eBook)
  • Build Web Servers with ESP32 and ESP8266 (eBook)
  • Firebase Web App with ESP32 and ESP8266 (eBook)
  • Free ESP32 Projects and Tutorials…
ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (2024)

FAQs

How to upload to ESP32 using Arduino IDE? ›

Troubleshooting
  1. Hold down the BOOT button on your ESP32 board.
  2. Press the Upload button in the Arduino IDE to upload a new sketch.
  3. Release the BOOT button when the Writing at 0x00001000… (100%) message appears in the Arduino IDE log after Connecting….
  4. You should now see the “Done uploading” message.

How to send data to cloud using Arduino and ESP32? ›

Need Help for connecting ESP32 to any cloud or Arduino Cloud
  1. Step 1: Prepare Arduino IDE for ESP32. ...
  2. Step 2: Connect ESP32 to Your Computer. ...
  3. Step 3: Arduino Cloud Configuration. ...
  4. Step 4: Install Arduino Create Agent. ...
  5. Step 5: Write the Sketch. ...
  6. Step 6: Upload Your Sketch. ...
  7. Step 7: Monitor and Test.
Feb 14, 2024

What is the difference between spiffs and LittleFS? ›

SPIFFS and LittleFS

Filesystem overhead on the flash is minimal as well. LittleFS is recently added and focuses on higher performance and directory support, but has higher filesystem and per-file overhead (4K minimum vs. SPIFFS' 256 byte minimum file allocation unit).

What is the use of LittleFS? ›

The little file system (LittleFS) is a fail-safe file system designed for embedded systems, specifically for microcontrollers that use external flash storage. Microcontrollers and flash storage present three challenges for embedded storage: power loss, wear and limited RAM and ROM.

Does ESP32 support LittleFS? ›

In this guide, you'll learn how to write and save data permanently to a file saved on the ESP32 filesystem (LittleFS). LittleFS is a lightweight filesystem created for microcontrollers that lets you access the flash memory like you would do in a standard file system on your computer, but simple and more limited.

Which Board to use for ESP32 in Arduino IDE? ›

There are various kinds of development board available that have esp32 chip on them like ESP32-DevKitC, NodeMcu-32S, LOLIN series etc. All of them function the same way. It can be programmed through various programming platforms like Arduino IDE, Espressif IoT Development Framework, Micropython, PlatformIO etc.

Which IDE is used for ESP32? ›

The Arduino IDE is widely used for ESP32 on Arduino development and offers a wide variety of configurations.

Can ESP32 be programmed with Arduino IDE? ›

There's an add-on for the Arduino IDE that allows you to program the ESP32 using the Arduino IDE and its programming language. In this tutorial we'll show you how to install the ESP32 board in Arduino IDE whether you're using Windows, Mac OS X or Linux.

Can ESP32 store data? ›

The ESP32 microcontroller's NVS is a useful way to store data without an SD card.

What is the secret key in Arduino IoT Cloud? ›

Instead when configuring a device, a secret key is generated, that can together with the device ID be used to securely connect to the Arduino Cloud. There are currently two official ESP32 based Arduino boards: Arduino UNO R4 WiFi. Arduino Nano ESP32.

How do I upload files to ESP32? ›

Create a directory named data and any files you want in the file system there. Make sure you have selected a board, port, and closed Serial Monitor. Select Tools > ESP32 Sketch Data Upload menu item. This should start uploading the files into ESP32 flash file system.

What is the alternative to LittleFS? ›

FatFS. FatFS is an alternative to the LittleFS File system, and is still actively maintained.

What is the maximum file size in LittleFS? ›

For LittleFS, the maximum file size in bytes is set in LFS_FILE_MAX and is standard set to 2147483647 (the max value of a int32_t). This is more than 2000MB, which is much more than 4MB of storage your ESP32 has. Hence, the maximum file size is practically limited by the flash size/size of the partition.

How do I upload code to ESP32 remotely? ›

You just need to follow these three steps.
  1. Step 1:- Uploading the WebUpdater Sketch. ...
  2. Step 2:- Access the Web-Server Created by Your ESP32. ...
  3. Step 3:- Get the Binary File of Your Code. ...
  4. Step 4:- Done!

How do I upload a bin to ESP32? ›

Method 1: Use the flash tool GUI application
  1. Connect the ESP32 to your computer using a USB cable.
  2. Open the ESP32 Flash Download Tool and select the "ESP32 Download Tool" option.
  3. Click the "Choose" button and navigate to the bin file you want to flash to the ESP32.
  4. Select the bin file and click "Open."

How do I upload OTA code to ESP32? ›

Upload a new sketch over-the-air to the ESP32

In your browser, on the ESP32 OTA Web Updater page, click the Choose File button. Select the . bin file generated previously, and then click Update. After a few seconds, the code should be successfully uploaded.

Top Articles
Latest Posts
Article information

Author: Carmelo Roob

Last Updated:

Views: 6759

Rating: 4.4 / 5 (45 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Carmelo Roob

Birthday: 1995-01-09

Address: Apt. 915 481 Sipes Cliff, New Gonzalobury, CO 80176

Phone: +6773780339780

Job: Sales Executive

Hobby: Gaming, Jogging, Rugby, Video gaming, Handball, Ice skating, Web surfing

Introduction: My name is Carmelo Roob, I am a modern, handsome, delightful, comfortable, attractive, vast, good person who loves writing and wants to share my knowledge and understanding with you.