WMM Power Save implementation on ESP32 Arduino?
Posted: Wed Jan 20, 2021 3:33 pm
Thank you for accepting me in this community.
Working on smart wall Wi-Fi thermostat, based on ESP32 and SHT35 temp/humidity sensor.
Though not battery operated, the power consumption is still critical as the slightest warming of the ESP32 module may alter the reading of the otherwise very precise SHT35 module (±0.1°C). So the ESP32 should stay in light sleep most of the time. (Modem sleep is far not enough, and I have some concerns even about automatic light sleep.)
Fortunately It’s OK to read the temperature just once every 10 seconds and to communicate with the Wi-Fi AP once every minute (actually at every 6th reading). In the meantime the thermostat should do nothing thus it can sleep (beside of watching some touch buttons, but this is hardware interrupt-based anyway).
The problem is that even the following code, executed once in a minute can create problems:
That’s because logging can take up to 3-4 seconds, obviously leading to full power consumption for a couple of seconds (heating), moreover, for a thing (sending and receiving a couple dozen of bytes) which should take just some milliseconds!
The lesson is that I should avoid repeated reconnecting on all costs.
Initially I thought all the people was right and you cannot maintain an association for a minute without turning on the WiFi. But there is a mode called WMM Power Save, available in all of modern routers (802.11n), where “instead of including a map in beacons the low-power device wakes up periodically at whatever rate it chooses and sends a probe to the access point to prompt delivery of any buffered packets.” That is, the AP knows that a certain connected device is sleeping and holds all the packets until the device wakes up, without losing the connection.
This is exactly what I need! Light sleep with RTC timer wakeup event every 10 sec for temp reading, and sending/receiving some little information over WiFi every minute, without needing to reconnect each time.
The problem is that I haven’t found yet any Arduino library or at least documentation for indicating how should I implement this behaviour for an ESP32 station.
I would appreciate if you helped me a bit for implement this WMM Power Save mode, as I’m a bit desperate now, have injected lots of precious time and resources in this project. Thanks!
Working on smart wall Wi-Fi thermostat, based on ESP32 and SHT35 temp/humidity sensor.
Though not battery operated, the power consumption is still critical as the slightest warming of the ESP32 module may alter the reading of the otherwise very precise SHT35 module (±0.1°C). So the ESP32 should stay in light sleep most of the time. (Modem sleep is far not enough, and I have some concerns even about automatic light sleep.)
Fortunately It’s OK to read the temperature just once every 10 seconds and to communicate with the Wi-Fi AP once every minute (actually at every 6th reading). In the meantime the thermostat should do nothing thus it can sleep (beside of watching some touch buttons, but this is hardware interrupt-based anyway).
The problem is that even the following code, executed once in a minute can create problems:
- Wifi.begin(SSID, password);
- while (WiFi.status() != WL_CONNECTED)
- delay(200);
The lesson is that I should avoid repeated reconnecting on all costs.
Initially I thought all the people was right and you cannot maintain an association for a minute without turning on the WiFi. But there is a mode called WMM Power Save, available in all of modern routers (802.11n), where “instead of including a map in beacons the low-power device wakes up periodically at whatever rate it chooses and sends a probe to the access point to prompt delivery of any buffered packets.” That is, the AP knows that a certain connected device is sleeping and holds all the packets until the device wakes up, without losing the connection.
This is exactly what I need! Light sleep with RTC timer wakeup event every 10 sec for temp reading, and sending/receiving some little information over WiFi every minute, without needing to reconnect each time.
The problem is that I haven’t found yet any Arduino library or at least documentation for indicating how should I implement this behaviour for an ESP32 station.
I would appreciate if you helped me a bit for implement this WMM Power Save mode, as I’m a bit desperate now, have injected lots of precious time and resources in this project. Thanks!