Page 1 of 1

Any lightweight alternative to WiFi lib ?

Posted: Tue May 24, 2022 7:23 am
by jnule1a
I am moving from ESP8266 to M5Stack C3U Stamp board. I am using Arduino IDE 1.8.19. Is there any lightweight alternative to the WiFi lib ? The WiFi lib consumes lots of flash memory (~600kB) if one compares it to the ESP8366WiFi lib. Actually, I only need to connect to an AP by providing the SSID and password, but I would wish to have Wifi and BLE at the same time in my sketch.

Re: Any lightweight alternative to WiFi lib ?

Posted: Tue May 24, 2022 7:33 am
by ESP_Sprite
Not really, but may I ask why 600K is an issue? That board has 4MiB to play around with; sounds like more than enough to me.

Re: Any lightweight alternative to WiFi lib ?

Posted: Tue May 24, 2022 8:02 am
by jnule1a
When I compile a simple sketch that just invokes the WiFi lib, I obtain the following info:
Sketch uses 637642 bytes (48%) of program storage space. Maximum is 1310720 bytes

The maximum usable flash is actually 1310720 even if the board has 4MB

If I compile a sketch that just invokes the Wifi+BLE, I obtain the following info:
Sketch uses 1152484 bytes (87%) of program storage space. Maximum is 1310720 bytes

So there is not much room available for real application code

Re: Any lightweight alternative to WiFi lib ?

Posted: Tue May 24, 2022 5:39 pm
by lbernstone
WiFi.h is just a wrapper for the underlying ESP-IDF APIs.
It is a total of 192K of code at the moment, so probably less than 15K compiled. I doubt you would find anything thinner than that.
The IDF APIs in turn are wrappers around the net80211 driver provided as a binary from Espressif. It might be possible to make that slimmer (it was in older versions of IDF), but presumably you want a robust and extensible framework for your network interfaces, even if you "just" want to type in your ssid and password. The whole IDF stack is probably about 150K of your 600K used.
The driver is what it is. It is the proprietary part bit of code that includes a lot of the secret sauce that gives the esp32 such power in a small bit of silicon. It is a 1M binary that you will probably use about half of in a typical deployment.
In summary, while it might be feasible to have a slimmer WiFi stack, nobody is going to invest the effort needed to do so when there is a team of professionals making a solid framework for their own product, particularly when you can buy a device with twice as much flash memory for $0.30 more.

Re: Any lightweight alternative to WiFi lib ?

Posted: Wed May 25, 2022 1:57 am
by ESP_Sprite
jnule1a wrote:
Tue May 24, 2022 8:02 am

The maximum usable flash is actually 1310720 even if the board has 4MB
That is because the ESP SDKs use a partition table to distinguish between data format; if you change the partition table, you can get more space allocated to the program. According to the Internet, the Arduino SDK should have partition table editing functionality under the 'Tools' menu.

Re: Any lightweight alternative to WiFi lib ?

Posted: Wed May 25, 2022 9:15 am
by lbernstone
There is a lighter weight BLE library. https://github.com/h2zero/NimBLE-Arduino

Re: Any lightweight alternative to WiFi lib ?

Posted: Wed May 25, 2022 4:09 pm
by jnule1a
Thank you so much ESP_Sprite and lbernstone.