Error compiling for ESP32

Sketch uses 1314058 bytes (100%) of program storage space. Maximum is 1310720 bytes.text section exceeds available space in board

Global variables use 51780 bytes (15%) of dynamic memory, leaving 275900 bytes for local variables. Maximum is 327680 bytes.
Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.
Error compiling for board ESP32 Dev Module.

Can someone help me with this Error? under is the code. I am trying things but nothing is working... :frowning:

#include <ThingSpeak.h> // add librery
#include <WiFi.h>

#include "BluetoothSerial.h"

BluetoothSerial SerialBT;

WiFiClient client;
unsigned long counterChannelNumber = 1; // Channel ID
const char * myCounterReadAPIKey = ""; // Read API Key
const int FieldNumber1 = 1; // The field you wish to read

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

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());
ThingSpeak.begin(client);

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());
ThingSpeak.begin(client);


      break;
    }
  }  
}    

}

int A = ThingSpeak.readLongField(counterChannelNumber, FieldNumber1, myCounterReadAPIKey);
Serial.println(A);
digitalWrite(LED1,A);
}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use [color = red]code tags[/color] (the </> icon above the compose window) to make it easier to read and copy for examination

The ESP32 only has ONE, 1 wireless transmitter.

BT and WiFi are loaded to core number 0.

The BT code takes up about 50% of the RAM available to core0. WiFi takes up about 50% of the ram available to core0. Then add in BT and WiFi stack space and you run out of RAM for core0.

Under Tools->Partition Scheme pick something other than the default (1.2MB APP, 1.5MB SPIFFS).

I would try "Minimal SPIFFS" which will give you 1.9MB of program space instead of 1.2MB.

3 Likes

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