Any lightweight alternative to WiFi lib ?

jnule1a
Posts: 6
Joined: Tue Apr 19, 2022 2:27 pm

Any lightweight alternative to WiFi lib ?

Postby jnule1a » Tue May 24, 2022 7:23 am

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.

ESP_Sprite
Posts: 9770
Joined: Thu Nov 26, 2015 4:08 am

Re: Any lightweight alternative to WiFi lib ?

Postby ESP_Sprite » Tue May 24, 2022 7:33 am

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.

jnule1a
Posts: 6
Joined: Tue Apr 19, 2022 2:27 pm

Re: Any lightweight alternative to WiFi lib ?

Postby jnule1a » Tue May 24, 2022 8:02 am

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

lbernstone
Posts: 831
Joined: Mon Jul 22, 2019 3:20 pm

Re: Any lightweight alternative to WiFi lib ?

Postby lbernstone » Tue May 24, 2022 5:39 pm

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.

ESP_Sprite
Posts: 9770
Joined: Thu Nov 26, 2015 4:08 am

Re: Any lightweight alternative to WiFi lib ?

Postby ESP_Sprite » Wed May 25, 2022 1:57 am

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.

lbernstone
Posts: 831
Joined: Mon Jul 22, 2019 3:20 pm

Re: Any lightweight alternative to WiFi lib ?

Postby lbernstone » Wed May 25, 2022 9:15 am

There is a lighter weight BLE library. https://github.com/h2zero/NimBLE-Arduino

jnule1a
Posts: 6
Joined: Tue Apr 19, 2022 2:27 pm

Re: Any lightweight alternative to WiFi lib ?

Postby jnule1a » Wed May 25, 2022 4:09 pm

Thank you so much ESP_Sprite and lbernstone.

Who is online

Users browsing this forum: No registered users and 35 guests