Enables or disables the imp WiFi sub-system’s power-save mode
Whether to enable (
Power-save mode is disabled by default. This means the WiFi radio receiver is enabled constantly. This results in the lowest latency for data transfers, but a high power drain - the actual power used depends on the imp variant, but can vary from 40 to 80mA at 3.3V.
Enabling power-save mode drops this down to <5mA when the radio is idle (ie. between transactions with the server), by using the IEEE PS mode feature. The STA (WiFi device) tells the AP (access point) that is is going into power save mode, and the AP will queue downstream traffic for the STA. The STA then only wakes to listen to AP beacons, which include a TIM (traffic indication map) which indicate if the AP is holding traffic for the STA. At other times, the wireless circuitry is powered down, resulting in the large power savings.
If the TIM indicates traffic is queued for the STA, the STA will send a PS Poll message to the AP, which causes it to send the queued traffic to the STA. Note that upstream traffic — STA to AP — is not affected by this, and the STA will transmit upstream packets immediately, as the AP is always listening.
Latency is impacted by use of IEEE PS mode. Typically the highest latency seen is a little over the DTIM (beacon interval), or around 100ms, but on congested networks — or with some APs that de-prioritize queued traffic — this can be several hundred milliseconds in addition to any transit latency seen in non-powersave mode.
You should note that from impOS™ 38 power-save mode will be disabled every time Squirrel restarts or reloads, such as across a deep sleep and subsequent warm start. For this reason, you may wish to ensure that your
imp.setpowersave(true) call appears as early as possible in your device code.
The imp.getpowersave() method can be used to determine whether power-save mode is currently in effect.
We do not currently recommend the use of WiFi powersave mode with imp004m-based designs. If you would like to use WiFi powersave mode on the imp004m, please contact us so we can explain the mode’s limitations and the module’s required wiring.
The impC001 does not currently implement imp.setpowersave().
The following snippet enables power-save mode on the imp and logs the fact.
The following simple application measures the average duration of a unit of data sent from the device to the agent and then back again, first in full-power WiFi mode and then in power-save mode. Each measurement is an average over 100 runs, but should not be taken as a precise measure of transmission time because of the many other factors involved. But it does give an indication of how power save mode may broadly affect your application.