Unfortunately I cannot in my sketch, like most users, just go to sleep to save power.
My instruments need a processing every 125 ms, a precise timing and network updates every second.
on the top of it, I need OTA.
What can I do in software to save power? Every mA counts.
I have seen, that the ESP8266 powers down the energy hungry WiFi interface during delay(); instructions.
But, my timing requires millis();
How can I power down WiFi without delay() just for the rest of my time budget?
Additionally, how much WiFi does the ArduinoOTA.handle(); consume and how frequently must it be run to be able to update a new sketch, while accepting a few minutes delay?
pylon:
If you hide your code we cannot help. A wiring diagram might also help, often connected devices might be put into sleep.
My code is rather complex.
You can find it, together with schematics and an extensive manual here: SPL-Booster
The sole connected device is a sound-pressure-level meter
It draws 11mA@5V and must run permanently.
(and, optionally an INA226 that draws 600microamps)
Currently, the biggest power hog is the ESP8266 with 0.55mA average@5V.
Currently, the biggest power hog is the ESP8266 with 0.55mA average@5V.
Compared to the 11mA of the SPL that's nothing although I don't think these numbers are correct.
The ESP8266 WiFi has two sleep states, WIFI_LIGHT_SLEEP and WIFI_MODEM_SLEEP, I guess the later will need too much time to reactivate, the former might save some mA.
Use setSleepMode() to set the mode you want, then forceSleepBegin() and forceSleepWake() to put the hardware into sleep and wake it.