melkati / CO2-Gadget

An advanced CO2 Monitor/Meter firmware for ESP32 with Android and iOS App for real time visualization and charting of air data, data logger, a variety of communication options (BLE, WIFI, MQTT, ESP-Now) and many supported sensors.
https://emariete.com/medidor-co2-gadget/
GNU General Public License v3.0
63 stars 13 forks source link

Memory use with all options enabled #63

Closed melkati closed 8 months ago

melkati commented 2 years ago

There are some memory issues (that's why this issue is also labeled as bug) when all options are enabled (WiFi, MQTT, BLE). We have reached the limits of memory.

Bluetooth library is tacking too much memory.

One possibility is to swap actual bluetooth library with NimBLE (a similar less memory angry library).

Right now, it forces to have to choose functionalities.

Memory use with WiFi, MQTT and Bluetooth:

RAM:   [==        ]  21.6% (used 70616 bytes from 327680 bytes)
Flash: [========= ]  94.4% (used 1856360 bytes from 1966080 bytes)

Memory use with WiFi, MQTT (without Bluetooth):

RAM:   [==        ]  16.1% (used 52632 bytes from 327680 bytes)
Flash: [======    ]  61.9% (used 1217832 bytes from 1966080 bytes)
melkati commented 2 years ago

Built rude version with NimBLE (without gadgetBle.handleEvents();) in branch Feature-NimBLE

Memory use with WiFi, MQTT and Bluetooth, using built in default Bluetooth library:

RAM:   [==        ]  22.1% (used 72528 bytes from 327680 bytes)
Flash: [==========]  95.8% (used 1882948 bytes from 1966080 bytes)

Exactly the same (WiFi, MQTT and Bluetooth) but using NimBLE library:

RAM:   [==        ]  21.1% (used 69160 bytes from 327680 bytes)
Flash: [========  ]  75.1% (used 1475880 bytes from 1966080 bytes)

Memory use with WiFi, MQTT (without Bluetooth).

RAM:   [==        ]  16.6% (used 54544 bytes from 327680 bytes)
Flash: [======    ]  63.4% (used 1247140 bytes from 1966080 bytes)

Great improvement! Everything, but fetch data logger buffer from Sensirion MyAmbience mobile App, works.

Now I need help to implement gadgetBle.handleEvents(); with the NimBLE library.

melkati commented 2 years ago

I just asked arduino-ble-gadget library author about this. https://github.com/Sensirion/arduino-ble-gadget/issues/11#issue-1087471599

melkati commented 2 years ago

The arduino-ble-gadget library author is already working on migrating it to the NimBLE bluetooth library. Hopefully, it doesn't take too much time and memory issues are solved with this, so CO2 Gadget can keep growing.

melkati commented 8 months ago

Upgrade to new Sensirion library version with NimBLE bluetooth library.