Sketch too big; Compilation error: text section exceeds available space in board

I tried to make a Wi-Fi manager with ble or Bluetooth but ı got a "sketch too big" error. How I solve this issue? My code :




#include <WiFi.h>

#include "BluetoothSerial.h"
 
BluetoothSerial SerialBT;

WiFiClient  client;
                              // The field you wish to read

String ssid_pass;
char *SSID1 = "POCO";
char *PASS = "9004652173";

String ssid;
String pass;

const int LED1 = 12;
const int LED_BT = 13;
const int SW = 14;

bool flag = false;

void setup()
{
  pinMode(LED1,OUTPUT);
  pinMode(LED_BT,OUTPUT);
  pinMode(SW,INPUT_PULLUP);
  
  Serial.begin(115200);
  Serial.println();

  WiFi.begin(SSID1, PASS);                 // write wifi name & password           

  Serial.print("Connecting");
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println();
  Serial.print("Connected, IP address: ");
  Serial.println(WiFi.localIP());
 

  if(!SerialBT.begin("ESP32"))
    {
      Serial.println("An error occurred initializing Bluetooth");
    }
}

void loop() 
{
  digitalWrite(LED_BT, LOW);
  int input = digitalRead(SW);
  Serial.print("input: ");Serial.println(input);
  if(input == 0)
  {
    delay(50);
    flag = true;
    digitalWrite(LED_BT, HIGH);
  }
  
  while(flag == true)
  { 
    
    while(SerialBT.available())
    {
      ssid_pass = SerialBT.readString();
      //Serial.write(SerialBT.read());
      Serial.println(ssid_pass);
  
      for (int i = 0; i < ssid_pass.length(); i++) 
      {
        if (ssid_pass.substring(i, i+1) == ",") 
        {
          ssid = ssid_pass.substring(0, i);
          pass = ssid_pass.substring(i+1);
          Serial.print("SSID = ");Serial.println(ssid);
          Serial.print("Password = ");Serial.println(pass);
          delay(2000);
          flag = false;

          int n1 = ssid.length();
    char char_array1[n1 + 1];
    strcpy(char_array1, ssid.c_str());
  
    int n2 = pass.length();
    char char_array2[n2 + 1];
    strcpy(char_array2, pass.c_str());
  

    WiFi.begin(char_array1, char_array2);                 // write wifi name & password           
  
    Serial.print("Connecting");
    while (WiFi.status() != WL_CONNECTED)
    {
      delay(500);
      Serial.print(".");
    }
    Serial.println();
    Serial.print("Connected, IP address: ");
    Serial.println(WiFi.localIP());
    


          break;
        }
      }  
    }    
  }
  
}


Code source : https://www.youtube.com/watch?v=5my1MScDvGE

My error :

It looks like you are using an ESP32. If so, which partition scheme have you got selected in the IDE ?

Default : Default 4MB with spiffs (1.2MB AP/1.5MB SPIFFS)
but I change with this : 8MB with spiffs (3MB AP/1.5MB SPIFFS) then I compiled code succussfully after that I uploaded code to esp32 board but I got a new issue in serial monitor like this:

How long are you spending in this while? The watchdog timer may time out if you take too long and don't call yield().

I didn't affect to code from the outside I only uploaded the code. I don't have any circuit I declared the flag = false first which means the code doesn't run inside this code block while (flag = true )

If you have a 4MB flash chip, you can't use a 8MB partition scheme.

Set another scheme that fits your actual dev-board specs.

try partition scheme "Hugh app (3MB no OTA/ 1MB SPIFFS)"

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.