ESP8266 Sketch Compile Fail on SPIFFS deprecated warning

Trying to compile this code which I have not modified/worked on for quite some time. I don't understand the SPIFFS error since I am using LittleFS commands. The deprecated warning never occurred before or at least it never prevented a successful comple. Is this because I am using the latest IDE 2.3.3 that has a new requirement/standard? Hopefuly there is a workaround for this that won't require code mods related to storing file information.

As a sidenote this ESP8266 has started freezing up after working fine for months on end. I thought about trying to do a forced reset periodically just to give it a fresh start every week or two, based on millis or date/time.


```cpp

#include <ESP8266WiFi.h>  

#include <LittleFS.h>
#include <time.h>  
#include <tz.h>   

#include <Arduino.h>
#ifdef ESP32
#include <WiFi.h>
#include <AsyncTCP.h>
#elif defined(ESP8266)
#include <ESPAsyncTCP.h>
#endif
#include <ESPAsyncWebSrv.h>

AsyncWebServer server(80);

const char *ssid = "Homestead-LAN_EXT";
const char *password = "********";
const char *PARAM_MESSAGE = "message";

int Initial_Connect_Attempts = 0;
int Try_Count = 0;

void notFound(AsyncWebServerRequest *request) {
  request->send(404, "text/plain", "Nope....notta....Not found");
}
int RunLEDState = LOW;
int OutageLEDState = LOW;

unsigned long currentMillis;
unsigned long previous_Blink_Millis = 0;
const long blink_interval = 2000;


unsigned long previous_TimeStamp_Millis = 0;
unsigned long previous_LED_Millis = 0;
const long TimeStamp_interval = 86400000;  // milliseconds [1 per day]

const long LED_interval = 200;  // Power Outage LED pulsate time period

const int Min_Voltage = 400;  // Input range 0 - 1023; 0 = 0 vdc, 1023 = 3 vdc
const int Restore_Voltage = 830;

bool update_clock = false;
bool Pwr_Restore_timestamp = false;
bool Pwr_Out_timestamp = false;
bool Outage_Detected = false;
bool End_Of_Outage = false;
bool Reset_Pressed = false;

const int Outage_LED = D7;        // GPIO13 = Bd. Label D7
const int LED_Reset_Button = D8;  // GPI15  = Bd. Label D8
int testOR0 = 0;                  // change to 1000 for testing

const int Vdc_Input = A0;  // ADCO   = Bd. Label A0

int Voltage_Value = 800;  // DC input from power module using voltage divider

void update_time();
void setup() {

  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  /* if (WiFi.waitForConnectResult() != WL_CONNECTED) {
        Serial.printf("WiFi Failed!\n");
        return;
    }
    */
  Serial.println("\nConnecting to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(1000);
  }
  Serial.print("IP Address: ");
  Serial.println(WiFi.localIP());

  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(200, "text/plain", "Enter /power for Outage file.");
  });
  server.on("/power", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(LittleFS, "PowerOutageFile.txt", "text/plain");
  });


  // Send a GET request to <IP>/get?message=<message>
  server.on("/get", HTTP_GET, [](AsyncWebServerRequest *request) {
    String message;
    if (request->hasParam(PARAM_MESSAGE)) {
      message = request->getParam(PARAM_MESSAGE)->value();
    } else {
      message = "What's up?";
    }
    request->send(200, "text/plain", "Hello, GET: " + message);
  });

  server.onNotFound(notFound);

  server.begin();

  //                    *********************************************************************
  Serial.setDebugOutput(true);

  configTime(TZ_America_Chicago, "pool.ntp.org", "time.nist.gov");
  Serial.println("\nWaiting for time");
  while (!time(nullptr)) {
    Serial.print(".");
    delay(1000);
  }
  if (!LittleFS.begin()) {
    Serial.println();
    Serial.println("Crap. An Error has occurred while mounting SPIFFS");
    return;
  }

  pinMode(LED_BUILTIN, OUTPUT);      // Processor run indicator
  pinMode(Outage_LED, OUTPUT);       // RED LED on shield
  pinMode(LED_Reset_Button, INPUT);  // Pushbutton on 8266 Shield

}

void loop() {
  time_t now = time(nullptr);
  Serial.println(ctime(&now));
  delay(testOR0);  // change to 1000 to slow serial output for testing

  currentMillis = millis();
  if (currentMillis - previous_Blink_Millis >= blink_interval) {
    previous_Blink_Millis = currentMillis;
    if (RunLEDState == LOW) {
      RunLEDState = HIGH;
    } else (RunLEDState = LOW);
    digitalWrite(LED_BUILTIN, RunLEDState);
  }

  if (currentMillis - previous_TimeStamp_Millis >= TimeStamp_interval) {
    previous_TimeStamp_Millis = currentMillis;
    update_clock = true;
  }

  Voltage_Value = analogRead(Vdc_Input);
  Serial.println("Voltage Input:  ");
  Serial.print(Voltage_Value);
  Serial.println();

  if (update_clock == true && Voltage_Value >= Restore_Voltage) {  // prevent timestamp update attempt
    update_time();                                                 // during power outage
    update_clock = false;
  }

  if (Voltage_Value <= Min_Voltage && Outage_Detected == false && Pwr_Out_timestamp == false) {
    Serial.print("Outage detected!  ");  // Low/No voltage detected.
    Serial.print("Outage Date/Time: ");
    Serial.println(ctime(&now));
    Serial.println();

    Pwr_Out_timestamp = true;
    Outage_Detected = true;

    File fileToAppend = LittleFS.open("/PowerOutageFile.txt", "a");

    if (!fileToAppend) {
      Serial.println("Crap. There was an error opening the file for appending outage detected.");
      return;
    }
    if (fileToAppend.print("Outage Start:    "))
      ;  // timestamp outage start time

    if (fileToAppend.println(ctime(&now))) {
      Serial.println("Yay! Timestamp was added.");
    } else {
      Serial.println("Crap. File append failed");
    }

    fileToAppend.close();
  }
  if (Voltage_Value >= Restore_Voltage && Outage_Detected == true && Pwr_Restore_timestamp == false)  // Outage ends : power returns
  {
    Pwr_Restore_timestamp = true;

    File fileToAppend = LittleFS.open("/PowerOutageFile.txt", "a");  // timestamp end of outage to file

    if (!fileToAppend) {
      Serial.println("Crap. There was an error opening the file for appending power restoration");
      return;
    }
    if (fileToAppend.print("Power Restored:  "))
      ;  // timestamp outage restoration time

    if (fileToAppend.println(ctime(&now))) {
      Serial.println("Yay! Power restored timestamp was appended to file!");
    } else {
      Serial.println("Crap. File append failed");
    }

    fileToAppend.close();

    End_Of_Outage = true;
    Serial.print("End Of Outage = ");
    Serial.println(End_Of_Outage);
    Serial.println();
  }

  if (digitalRead(LED_Reset_Button) == HIGH)  // reset button pressed to acknowledge outage
  {                                           // and reset boolean flags
    End_Of_Outage = false;
    Outage_Detected = false;
    Pwr_Restore_timestamp = false;
    Pwr_Out_timestamp = false;
    digitalWrite(Outage_LED, LOW);  // Turn off Red LED
    Serial.print("End Of Outage =   ");
    Serial.println(End_Of_Outage);
    Serial.println();
    Serial.print("Outage Detected =   ");
    Serial.println(Outage_Detected);
    Serial.println();
  }

  if (Pwr_Restore_timestamp == true)  // Pulsate Power Outage LED AFTER power returns
  {
    if (currentMillis - previous_LED_Millis >= LED_interval) {
      previous_LED_Millis = currentMillis;
      if (OutageLEDState == LOW) {
        OutageLEDState = HIGH;
      } else {
        OutageLEDState = LOW;
      }
      digitalWrite(Outage_LED, OutageLEDState);
    }
  } 
  

}

void update_time() {

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    Initial_Connect_Attempts++;
    Serial.println("Attempting to Connect To Local Network:   ");
    Serial.println(ssid);
    WiFi.begin(ssid, password);
    delay(4000);
    if (Initial_Connect_Attempts == 5) return ;  // give up after 5 trys and wait for next cycle
    Serial.print(".");
  }

  configTime(TZ_America_Chicago, "pool.ntp.org", "time.nist.gov");
  Serial.println("\nWaiting for time");
  while (!time(nullptr)) {
    Serial.print(".");
    delay(1000);
  }
}

In file included from c:\Users\Ed\IDE 2.0 Sketches-Libraries\libraries\ESPAsyncWebSrv\src\WebAuthentication.cpp:21:
c:\Users\Ed\IDE 2.0 Sketches-Libraries\libraries\ESPAsyncWebSrv\src\WebAuthentication.h:27:51: error: missing binary operator before token "("
27 | #if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
| ^
In file included from c:\Users\Ed\IDE 2.0 Sketches-Libraries\libraries\ESPAsyncWebSrv\src\WebRequest.cpp:23:
c:\Users\Ed\IDE 2.0 Sketches-Libraries\libraries\ESPAsyncWebSrv\src\WebAuthentication.h:27:51: error: missing binary operator before token "("
27 | #if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
| ^
In file included from c:\Users\Ed\IDE 2.0 Sketches-Libraries\libraries\ESPAsyncWebSrv\src\SPIFFSEditor.cpp:1:
c:\Users\Ed\IDE 2.0 Sketches-Libraries\libraries\ESPAsyncWebSrv\src\SPIFFSEditor.h:16:101: warning: 'SPIFFS' is deprecated: SPIFFS has been deprecated. Please consider moving to LittleFS or other filesystems. [-Wdeprecated-declarations]
16 | SPIFFSEditor(const String& username=String(), const String& password=String(), const fs::FS& fs=SPIFFS);
| ^~~~~~
In file included from c:\Users\Ed\IDE 2.0 Sketches-Libraries\libraries\ESPAsyncWebSrv\src/ESPAsyncWebSrv.h:27,
from c:\Users\Ed\IDE 2.0 Sketches-Libraries\libraries\ESPAsyncWebSrv\src\SPIFFSEditor.h:3,
from c:\Users\Ed\IDE 2.0 Sketches-Libraries\libraries\ESPAsyncWebSrv\src\SPIFFSEditor.cpp:1:
C:\Users\Ed\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/FS.h:286:15: note: declared here
286 | extern fs::FS SPIFFS attribute((deprecated("SPIFFS has been deprecated. Please consider moving to LittleFS or other filesystems.")));
| ^~~~~~

exit status 1

Compilation error: exit status 1

Nothing to do with the IDE, the author of the SPIFFS library is no longer maintaining it. It may continue to work but no guarantees. One of the sample sketches for the 8266 is a program to convert from Spiffs to LittleFS . It is called Basic_example, check it out.

The deprecation is just a warning, and separate. Look for the word "error:". (Also post errors as code, so that any spaces that would position the ^ marker are not coalesced into a single space, among other things.)

Looks like you're using ESPAsyncWebSrv, which is a fork of ESPAsyncWebServer. The most recent release of the former, 1.2.8, about three months ago, adds detection for arduino-esp32 v3. It relies on the ESP_ARDUINO_VERSION_VAL macro -- the one that is hinted at by the error message as missing -- which is defined for ESP32, not ESP8266.

So try reverting the ESPAsyncWebSrv library to the earlier 1.2.7, which is just over a year old.

1 Like

`#include <LittleFS.h>`



`File fileToAppend = LittleFS.open("/PowerOutageFile.txt", "a");`
[/quote]


I thought I was using LittleFS. ???

Right, but the compile still aborts.

I will definitely try this suggestion. Trying to not have to rewrite my sketch if at all possible.

If you post the error log (verbose please) in code tags it is easy for us to decipher it

You have errors, but I also note a reference to Ver 3, is this a migration issue?
https://docs.espressif.com/projects/arduino-esp32/en/latest/migration_guides/2.x_to_3.0.html

One of your libraries is using SPIFFS, maybe your compile error level is set to low to display but mine isn't

In file included from /Users/ronalexander/Library/CloudStorage/OneDrive-Personal/Documents/Electronics/SourceCode/Arduino/libraries/ESPAsyncWebSrv/src/SPIFFSEditor.cpp:1:
/Users/ronalexander/Library/CloudStorage/OneDrive-Personal/Documents/Electronics/SourceCode/Arduino/libraries/ESPAsyncWebSrv/src/SPIFFSEditor.h:16:101: warning: 'SPIFFS' is deprecated: SPIFFS has been deprecated. Please consider moving to LittleFS or other filesystems. [-Wdeprecated-declarations]
   16 |     SPIFFSEditor(const String& username=String(), const String& password=String(), const fs::FS& fs=SPIFFS);

This error is weird, there are major breaks in V3 but this is just the test for V3. I strongly suggest you either change the library or back level it.
I just reverted the 8266 boards to 2.x and still get the error.
GOOD NEWS I took the ESPAsyncWebSrv back to 1.2.3 and it compiles clean.

  • SPIFFS Warning with LittleFS: The warning may be from library dependencies or stricter checks in Arduino IDE 2.3.3. Ensure all references are to LittleFS only. Initialize it explicitly as:
if (!LittleFS.begin()) {
    Serial.println("Failed to mount LittleFS");
    return;
}
  • ESP8266 Freezing Solution: Schedule a reset every 7 days to improve stability:
unsigned long lastResetMillis = 0;
const unsigned long resetInterval = 7UL * 24 * 60 * 60 * 1000;  // 7 days

void loop() {
    if (millis() - lastResetMillis >= resetInterval) {
        ESP.restart();
    }
}
  • Memory Checks: Add ESP.getFreeHeap() in key points to monitor available memory, which helps catch memory issues over time.
1 Like

I think I have to go to Preferences to change the verbose output setting.

As to printing it in code format what I have been doing is just selecting the compile messaging using the block message at the bottom that says "copy message."

Do I need to go to Edit and select "Copy For Forum" and then go down and copy the
compiler messaging? And this provides the formatting you recommended?

jfsc,

Nothing personal but I would give you a big fat wet kiss on the cheek for
your extremely helpful reply!!!! :heart: :heart: :heart:

Thank you very much!!!!!

Bingo!!!!!!!!

Thank you very much Ken.... :+1: :+1: :+1:

I want to thank everyone, including jfsc, Kenb4, & sonofcy for providing
very helpful suggestions! :white_check_mark: :white_check_mark: :white_check_mark:

I am still a little confused about the difference between SPIFFS and LittleFS with the
error messaging as I was calling LittleFS in the code. But I will wade into that further for a beter understanding.

Thanks everybody!!

Yes, either copy for forum or use the ^^^ when posting whichever you find most convenient.

After you revert the ESPAsyncWebSrv back to 1.2.7 make the following changes so auto update still works, but the ESPAsyncWebSrv will NOT update.


Screenshot 2024-11-09 at 14.57.07

Thank You !!!!

I take it the '9.9.9' fakes the updater into thinking it has the latest greatest....

Correct, otherwise you either can't do automatic bulk updates.
REMEMBER, you need to STOP using that library, it is deprecated and no longer works unless you mess with it as we did.
It may stop working again at any time.

Now I am getting out of my wheelhouse. I have no idea.

So to avoid this library from becoming inoperative I need to check out your recommendation. I do not like band-aid approaches even if they work....lol.

It's a trivial bug but I couldn't find an Issues thingy so I posted here and tagged one of the arduino support guys. It should get fixed very quickly but you don't need to wait for the fix. Just carry on and when it is fixed (someone will tell you how to get notified) then you can install the latest version. I copied you on the post so you should get notified.

1 Like