This tutorial shows how to add an SPIFFS data partition to an ESP32 Arduino project in order to store various resources. We will show how to add 2 sample files to the partition, program it into the FLASH memory and use the SPIFFS API to read the file contents programmatically.
Before you begin, install VisualGDB 5.5 or later.
Serial.begin(115200); if (!SPIFFS.begin(false)) { Serial.println("SPIFFS Mount Failed"); return; } File rootDir = SPIFFS.open("/"); if (rootDir) { for (File file = rootDir.openNextFile(); file; file = rootDir.openNextFile()) { Serial.printf("[%s (%d bytes)]\r\n", file.name(), file.size()); while (file.available()) { String str = file.readStringUntil('\n'); Serial.printf("\t%s\r\n", str.c_str()); } } }
Serial.begin(115200); if (!SPIFFS.begin(false)) { Serial.println("SPIFFS Mount Failed"); return; } File rootDir = SPIFFS.open("/"); if (rootDir) { for (File file = rootDir.openNextFile(); file; file = rootDir.openNextFile()) { Serial.printf("[%s (%d bytes)]\r\n", file.name(), file.size()); while (file.available()) { String str = file.readStringUntil('\n'); Serial.printf("\t%s\r\n", str.c_str()); } } }
The code mounts the SPIFFS partition and then iterates over all files, printing their contents line-by-line.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4