Why does this little program occupy 80% storage in my ESP32? any solutions?

#include "BluetoothSerial.h"
 
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
 
BluetoothSerial SerialBT;
 
void setup() {
  Serial.begin(115200);
  SerialBT.begin("ESP32test"); //Bluetooth device name
  Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() { 
  for(int i=1; i<10000; i++){
    SerialBT.print("this is the sample number: "); SerialBT.println(i);
    delay(1);
  }
}

1 Like

I moved your topic to an appropriate forum category @venkat_yalamati.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

The library you are using makes your program not so little. It consumes lots of memory

Pretty much the answer given to @venkat_yalamati at Stack Exchange too:

Perhaps this time with two answers it can be accepted.

4 Likes

for example a recent project using BLE the linker reported

Sketch uses 1548805 bytes (49%) of program storage space. Maximum is 3145728 bytes.
Global variables use 62488 bytes (19%) of dynamic memory, leaving 265192 bytes for local variables. Maximum is 327680 bytes.

removing BLE and switching to use WiFi

Sketch uses 879001 bytes (27%) of program storage space. Maximum is 3145728 bytes.
Global variables use 46712 bytes (14%) of dynamic memory, leaving 280968 bytes for local variables. Maximum is 327680 bytes.

both using the ESP32 "Hugh app (3MB No OTA/1M SPIFFS" partition scheme

1 Like

Hi ledsyn.. I agreed that it is due to BLE/bluetooth library... but any soultion for this? alternate library which is more efficient in storage space?

BLE is a very complex protocol hence large and complex code

under Tools>partition scheme select "Hugh app (3MB no OTA/ 1MB SPIFFS)"

4 Likes

Thanks horace!! it worked.. the storage space is now increase to 3MB & the program occupied percentage reduced to 33% from 80%. So, in a normal atmega328 based BT project (using HC-05/06/08 modules), BT protocol implementation code will be present inside the HC-0X modules hence there is no need for atmega328 to carry that code right?

1 Like

correct! I have used the Microchip BM71 module (which has BLE onboard) with PIC24 microcontrollers
however, the ESP32 has the advantage it also supports the Bluetooth Classic and WiFi
was useful recently when a project end-user changed the specification from a BLE app to WiFi webserver - no redesign of hardware and making new PCBs

2 Likes

If I may recommend; take a moment to mark the post that answered your question as the Solution - that user will be happy for credit given.

Hope I didn't use all my quota of bold today. :upside_down_face:

Careful - the S3 does not support classic BT.

thought we were talking about the ESP32 - see comparison table which compares the Espressif devices

1 Like

done!!!

Well, that's not the answer to your question...

In the wider context I guess the wording Solution is bad, perhaps Answer would be better. (This isn't an issue only in this thread.)

Right - the table shows it only supports BLE 5.0. This does not mean it is compatible with the classic BR/EDR, some chips support both but not the esp32-s3.

the image in post 1 shows that the board selected is a ESP32-WROOM-DA not a ESP32-S3 - did the device change at some point?

I was pointing out that esp32 is a series of different chips and the supported features are different. Not all support classic Bluetooth. You have to check the individual module spec to see what is supported.

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