Reduce Library Sizes

Hello all! I hope you guys can help me with my problem.

I am working on building a wireless gamepad using an ESP32. To make the wireless gamepad work I need two things:

  • Send keyboard strokes over Bluetooth
  • Program the individual buttons with the Blynk app

For this I am using two libraries:

// Blynk WiFi Connection Library
#include <BlynkSimpleEsp32.h>

// Bluetooth Keyboard Library
#include <BleKeyboard.h>

However, when I try to use libraries & compile the project I get the following error message:

Sketch uses 1355462 bytes (103%) of program storage space. Maximum is 1310720 bytes.

Global variables use 58980 bytes (17%) of dynamic memory, leaving 268700 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.

It is clear that the libraries are too big for the ESP32. So I was wondering if there is a way to reduce the size of one of these libraries? If so, how?

Not an ESP user, but I think that you will have to post your full code for anybody to be able to determine what is going on.

teije:
It is clear that the libraries are too big for the ESP32.

No it isn't.
The real problem is that your code is too big for the ESP32. The libraries are simply convenient ways to code which is why everybody uses them. Material in the library that is superfluous to your needs is ignored during compilation. You could dispense with the libraries altogether and do the whole job yourself but code is code so you needn't expect any worthwhile decrease in the storage space required.

As a case in point, I never use an RTC library, I just use a routine that I got to work first and have never had a need to change. I have checked it against RTC.lib, and found I save only about a dozen bytes.

I have never heard of anybody running out of memory on an ESP32 before. I would not have thought those libraries were particularly demanding. It is just possible that they are incredibly badly written, but I think you have simply chosen the wrong MCU for the job - whatever that is.

I seem to recall that use of Bluetooth on the ESP32 consumes a very large percentage of the available Flash space.

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