Closed
Description
This is a small code sample that read and write to Little FS on ESP32.
#include "WiFi.h"
#include <FS.h>
#include <LittleFS.h>
void setup() {
Serial.begin(115200);
// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
Serial.println("Setup done");
if (!LittleFS.begin(true)) {
Serial.println("Formatted");
} else {
Serial.println("Formatteddd");
LittleFS.format();
}
File file = LittleFS.open("/prova.txt", "w");
//Write to the file
file.print("dsadasdsa");
delay(1);
//Close the file
file.close();
Serial.println("wrote");
File file2 = LittleFS.open("/prova.txt", "r");
if (!file2) {
Serial.println("No Saved Data!");
}
Serial.println(file2.read());
}
void loop() {
Serial.println("scan start");
// WiFi.scanNetworks will return the number of networks found
int n = WiFi.scanNetworks();
Serial.println("scan done");
if (n == 0) {
Serial.println("no networks found");
} else {
Serial.print(n);
Serial.println(" networks found");
for (int i = 0; i < n; ++i) {
// Print SSID and RSSI for each network found
Serial.print(i + 1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(")");
Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? " " : "*");
delay(10);
}
}
Serial.println("");
// Wait a bit before scanning again
delay(5000);
}
if I use a TinyPICO board, this small snippet fails reading writing LittleFS when using
[email protected]
it works well when using
[email protected]
I noticed that the only way to make it work with
[email protected]
is to use
board_build.flash_mode = qio
instead of
board_build.flash_mode = dio
but this does not have sense to me.
when using [email protected]
that snippet works with both QIO
and DIO
.
the problem happen on TinyPICO board only, it does not happen on LolinD32 or other ESP32 boards I have.
Same snipped always works well with Arduino IDE when using Core 2.0.4.