Sketch too big. Some can help me reduce storage

Sketch uses 1299853 bytes (99%) of program storage space. Maximum is 1310720 bytes.
Global variables use 45216 bytes (13%) of dynamic memory, leaving 282464 bytes for local variables. Maximum is 327680 bytes.

My code using Firebase and WifiManager to send message:

#include <WiFiManager.h> 
#include <FirebaseESP32.h>

WiFiManager wm;

FirebaseAuth auth;
FirebaseConfig config;
FirebaseData firebaseData;

String DeviceCode = "Device1";

float temperature = 0.0;
float heartbeat = 0.0;
float SpO2 = 0.0;
float count = 0.0;

void connectToWiFi() {
  bool res;
  res = wm.autoConnect("Spirit", "12345678"); 

  if (!res) {
    Serial.println("Failed to connect");
  } else {
    Serial.println("Connected to WiFi");
  }
}

void connectToFirebase() {
  config.host = "";
  config.api_key = "";

  auth.user.email = "";
  auth.user.password = "";

  Firebase.begin(&config, &auth);

  if (Firebase.ready()) {
    Serial.println("Firebase initialized successfully");
  } else {
    Serial.println("Failed to initialize Firebase");
  }
}

void setup() {
  Serial.begin(115200);

  connectToWiFi();

  connectToFirebase();
}

void loop() {


  if (WiFi.status() == WL_CONNECTED && Firebase.ready()) {

    temperature = 37.0 + count;
    heartbeat = 87.0 + count;
    SpO2 = 97.0 + count;

    Firebase.setFloat(firebaseData, "/" + DeviceCode + "/Temperature", temperature);
    Firebase.setFloat(firebaseData, "/" + DeviceCode + "/HeartBeat", heartbeat);
    Firebase.setFloat(firebaseData, "/" + DeviceCode + "/SpO2", SpO2);
    count++;
    if (firebaseData.dataAvailable()) {
      Serial.println("Data sent to Firebase successfully");
    } else {
      Serial.println("Failed to send data to Firebase");
      Serial.println(firebaseData.errorReason());
    }
  } else {
    Serial.println("WiFi or Firebase not ready");
  }

  Serial.print("Temperature: ");
  Serial.println(temperature);
  Serial.print(", HeartBeat: ");
  Serial.println(heartbeat);
  Serial.print(", SpO2: ");
  Serial.println(SpO2);
  
  Serial.println();
  delay(5000);
}

Amazing. All that library code, just to send three numbers!

1 Like

Hi @panda-so ,

Welcome to the forum..
Think you're going to have to change your partition scheme..
Try "Huge App" if it's available..
This is selected under the tools menu in your ide..

Good luck.. ~q

1 Like

Thanks for your reply. Since this is my first time using it, what libraries should I only use to estimate storage

Sorry, I know nothing about Firebase. Try the partition suggestion above.

1 Like

According my research, The "Huge App" is adding the following lines to boards.txt right:

lolin32.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
lolin32.menu.PartitionScheme.huge_app.build.partitions=huge_app
lolin32.menu.PartitionScheme.huge_app.upload.maximum_size=3145728

Partition scheme is under the Tools menu for me..
Don't need to edit any file here..
Could be different for you particular board..

~q

1 Like

Why is 99% too much?
It simply fits...

Using the "F" macro will reduce some of your storage requirements.

1 Like

If it fits into program memory, there is no problem.

See reply #8: you have over 10K bytes of program memory left to fill.

On a Uno etc., that may help reduce RAM usage. On the ESP32 the compiler automatically assigns all constants to flash memory so, as far as I understand, the F() macro is not required at all.

1 Like

Wow it really work! 99% to 43%. Thanks

1 Like

it is a "wow" indeed...
What did you do to obtain a such result?

I use "Huge App", u can read the comment above

1 Like