0

I'm trying to check the total size and the used bytes of the Flash-FileSystem on an ESP8266.

I'm using Arduino IDE (2.0.1) with "esp8266 by ESP8266 Community" (3.0.2)

I found in different tutorials the commands

#import <FS.h>

SPIFFS.usedBytes();
SPIFFS.totalBytes();

Also in the arduino-esp32-documentation I found this functions, but the compiler says:

In file included from C:\Users\...\esp8266_temp_humid_log_with_http.ino:38:
C:\Users\...\http_serving.h: In function 'void showFilesize()':
C:\Users\...\http_serving.h:42:24: error: 'class fs::FS' has no member named 'totalBytes'
   42 |   int tBytes = SPIFFS.totalBytes();
      |                        ^~~~~~~~~~
C:\Users\...\http_serving.h:45:25: error: 'class fs::FS' has no member named 'usedBytes'
   45 |   int uBytes = SPIFFS.usedBytes();
      |                         ^~~~~~~~~

exit status 1

Compilation error: 'class fs::FS' has no member named 'totalBytes'

I know, SPIFFS is depricated. I also tried LittleFS with the same result. Unfortunally I cant find the library on my folders to take a look into it.

I don't get it, why this function is not available.

May anyone have an idea to solve the problem?

Thanks a lot.

Zaby1990
  • 21
  • 6
  • read the doc https://arduino-esp8266.readthedocs.io/en/3.0.2/filesystem.html#info. You can find the location of boards packages in Arduino IDE Preferences as the location of the preferences.txt file at the bottom of the Preferences dialog. It is clickable and opens the folder. There find the boards package in packages folder. or https://github.com/esp8266/Arduino/tree/master/libraries/LittleFS/src. – Juraj Nov 02 '22 at 18:20
  • thank you, the first link helps very much – Zaby1990 Nov 03 '22 at 06:07

1 Answers1

0

the comment from Juraj helps me to solve the problem:

FSInfo fs_info;
SPIFFS.info(fs_info);
long usedBytes = fs_info.usedBytes;
long totalBytes = fs_info.totalBytes;

Thanks for the help.

Mustafa Poya
  • 2,615
  • 5
  • 22
  • 36
Zaby1990
  • 21
  • 6