LittleFS Implemetation on ESP8266

LittleFS is a file system which replace the SPIFFS system. These file systems using to creating file system on microcontroller.Just an example you can create a txt file with these file systems.You can manage various type of file types. Html, css, js, txt, gzip, etc. all these file types can be transferred to microcontroller memory(flash).

You can find more information about the file systems. In this article I will show how could we imlement this system on .txt files.

Why .txt files could require in our system? If you have to recognize some variables , credentials(e.g. W.-Fi) or other datas then you have to store that things in a memory-like storage systems.You can use SD-Card , EEPROM , some other memory elements or flash. SD-Card implementation could be perfect for huge amount of datas.For an example if you are trying to save JPEG files and amount of the files are about 1000 or more then only SD-Card can solve the problem.EEPROM is the memory element to store the elements byte-one-byte and most of the time EEPROM is limited by at most 1M-Bit storage capacity. Flash system is placing middle of them. Flash system generally has 4–8–16 MB capacity.Beside you don’t have to use external memory element(SD-Card , EEPROM).

Let look at the my library. https://github.com/firtinahg/FileOperations

This library is for ESP8266 boards. I assume that in your Arduino IDE there is a ESP8266 boards.(NodeMCU etc.)

To using library you have to follow the steps;

1-Open your Arduino IDE

2-Click “Sketch” → “Include Lıbrary” → “Manage Library” → type “LittleFS” and find “LittleFS_esp32” click install.

3-Go to the link(https://github.com/firtinahg/FileOperations) and download the file.

4-Add it to your library environment(Arduino library).

If you can do it correctly you can find the example in Arduino IDE clicking to “File” → “Examples” → “Examples from custom libraries” → “FileOperations” → “Demo”

In Demo file you can see the example usage of the library.

FileOp FileExample;

This is a constructing the file with an after naming convention. If you would like to implement it with a specific text file name please use that;

FileOp FileExample(“/example_file.txt”);

Let look at the methods of the class :

1- getCurrentPathName() → it gives the file name which you’re current use to write , read or append.

2-IsDirectory() → It returns true or false. If file is a directory which means file has at least 1 character in it then it returns true. Otherwise returns false.

3-definePath() → If you would like construct the File directly with specific file name you can use the FileOp FileExample(“/example_file.txt”) method.If you would like to define the text file later you can use the method(definePath()).

4-Rename() → Rename your current file.

5- Write() → Write to current file.If you would like to add some characters to the file which wrotten before, you have to use append method.If you use this method then file starts with the new content.

6- Append() → Adding new info’s to existing file.

7-Read() → Reading current file.

8- Delete() → Deleting current file.

9-GetSize() → It returns the size of the current file(bytes).

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store