ESPimatic uses a lot of librarys. These librarys are used by sensors/device.
The problem is : you can disable a sensor/device(/plugin) but that won’t stop the library from being loaded in memory.
Some facts that 'm aware of (please do correct me if I’m wrong) :
- You can only do a include before the setup() routine
- You can only do a library include in the main sketch (not in a included file)
- Starting a libray can only be done before the setup() routine (might depende on the library)
- Arduino IDE compile will not compile a library that is entirely unused in the sketch
- Wether you eventually use a library or not in the code, the library is consuming memory
With these ‘facts’ in mind: For ESPimatic I have created sepearate .h files per plugin. All the code for a plugin is in that one file. I can’t put extra includes for a library in the .h file because the Arduino IDE ignores it during compile. This puts me in a situation to do all the library includes on top of the main sketch. Same goes for starting these librarys.
This results in the library being loaded by the ESP even if the specific plugin is disabled (and not used) in ESPimatic.
Does above story makes sense? Could someone give me some tricks on how to prevent a arduino/esp library being loaded if I don;t plan to use after booting the ESP ?