Saving power on an ESP8266 web server using delays
The ESP8266 has 5 sleep modes, as summarized by this README.md in the Arduino ESP8266 Core: <a href="https:&#x2F;&#x2F;github.com&#x2F;esp8266&#x2F;Arduino&#x2F;tree&#x2F;master&#x2F;libraries&#x2F;esp8266&#x2F;examples&#x2F;LowPowerDemo">https:&#x2F;&#x2F;github.com&#x2F;esp8266&#x2F;Arduino&#x2F;tree&#x2F;master&#x2F;libraries&#x2F;esp...</a><p>The `delay(1)` triggers the &quot;Automatic Modem Sleep&quot; mode, which keeps the WiFi connection alive. It should draw about 15-16 mA, which is pretty close to the 18-24 mA measured in the TFA.<p>The WiFi radio consumes a lot of power. During initialization, I believe it can consume 500 mA or more. In normal usage, WiFi apparently has a continuous drain of ~70 mA. If WiFi is not needed, the ESP8266 can be placed into &quot;Forced Deep Sleep&quot; mode, with an idle current of 0.02 mA. Using a ~2000 mAh battery (e.g. 3xAA NiMh, or 1x18650 Li-Ion), that means over 11 years on battery, if no other work is performed. The lowest current that I have measured personally is 0.04 mA on various ESP-01 modules. But that still means about 5.5 years on a single charge.<p>If the WiFi is needed only intermittently, the ESP8266 can be placed into &quot;Forced Deep Sleep&quot; mode, with the internal RTC configured to wake it up after a certain time, e.g. 15-30 minutes. It can then connect to WiFi, transmit the data payload, then go back to Deep Sleep again. Unfortunately, the ESP-01 module does <i>not</i> support this (without hardware hacking), because it does not expose the GPIO16&#x2F;D0 pin necessary to trigger the RESET.<p>Other ESP8266 dev boards (e.g. D1 Mini, NodeMCU) do support waking up from Deep Sleep. But these dev boards often contain a voltage regulator which consumes a quiescent current. On my D1 Mini boards, I get about 0.22 mA in Forced Deep Sleep mode. In theory, that&#x27;s enough for 1 year of life on a single charge of a 2000 mAh battery. But waking it up every 15 minutes, for 5-6 seconds of WiFi time, reduces the battery life to about 4-5 months. At this point, the active power usage during the 5-6 seconds of WiFi is already 2X the power consumption of the 15 minutes of Deep Sleep, so I have not attempted to reduce the idle consumption any further.