Notes / esp32arduinowifim5stackcardputer
ESP32-S3 Arduino Wi-Fi HTTP downloads crawl at about 1 KB/s
HTTP(S) downloads to SD from an ESP32-S3 Arduino sketch (M5Stack Cardputer-ADV) ran at about 1 KB/s. The cause was Wi-Fi modem power-save. Calling WiFi.setSleep(false) after connecting raised it to about 85 KB/s.
Symptoms #
An Arduino MP3 player sketch on an M5Stack Cardputer-ADV downloads MP3 files over Wi-Fi and writes them to the microSD card. Throughput was about 1 KB/s.
Root cause #
Wi-Fi modem power-save. Turning it off was the only change needed, which is how it was identified.
Background (general ESP32 behaviour, not separately measured here): in station mode the ESP32 Wi-Fi driver uses modem sleep by default, so the radio dozes between access-point beacons. That is fine for occasional small requests but throttles a long bulk download.
Fix #
Turn modem sleep off once the station is up:
cpp#include <WiFi.h>
WiFi.mode(WIFI_STA);
WiFi.begin("your-ssid", "your-wifi-password");
while (WiFi.status() != WL_CONNECTED) delay(100);
WiFi.setSleep(false); // disable modem power-save
With this one change, downloads went from about 1 KB/s to about 85 KB/s, and the files were verified byte for byte.
Caveat (not measured here): with sleep off the radio stays awake, so expect higher current draw while Wi-Fi is on. On a battery device, turn Wi-Fi off when the transfer is done.