cesanta / mongoose-os

Mongoose OS - an IoT Firmware Development Framework. Supported microcontrollers: ESP32, ESP8266, CC3220, CC3200, STM32F4, STM32L4, STM32F7. Amazon AWS IoT, Microsoft Azure, Google IoT Core integrated. Code in C or JavaScript.
https://mongoose-os.com
Other
2.48k stars 430 forks source link

Power Management in ESP32 #594

Closed subhash-coder closed 2 years ago

subhash-coder commented 2 years ago

Hello, I'm using esp32 with an esp-idf development environment, my project is camera_web_server, where it sends a stream of JPEG images to a browser when I click on the "start stream" button on a web page, so what I need to do is, keep my ESP32 in low power mode until it gets a request from a web browser.

alnunez commented 2 years ago

Hi. Most of the power consumption of ESP32 came from WiFi. If you are waiting for a web request, you need to keep WiFi turned on all time, so there is no much power you can save at all.

rojer commented 2 years ago

well, this is not quite true. devices only need to be active occasionally, to maintain association with the AP. ESP32 has different power-saving modes that make it turn radio off when not needed. bu default it's off (0), but you can set wifi.sta_ps_mode to 1 or 2 for different degree of power saving.

scaprile commented 2 years ago

I don't know if this is the right place (nor if it is my call), if you want to discuss all things your project meet me at the forum. In my case I don't see a server being able to sleep unless the AP has some form of store & forward. The browser's SYN can come at any time and you must be awake to handle it or the IP datagram be queued at the AP until you say hi after the beacon. Unfortunately there's been quite more than a long decade since I was toying with end-devices sleeping on a WiFi network, never with a sleeping server, and that feature might already be built-in on newer APs; IIRC it was not for 802.11b/g and I would risk saying that neither it was for n.

rojer commented 2 years ago

indeed, deep sleep is unlikely to be possible just because of how disruptive it is, but wifi radio can be put to sleep between beacons, that's what ps_mode does, essentially. there might be slight delay to reacting to connections, yes.