8 ms·
Saving power on an ESP8266 web server using delays
- mromanuk 4y ago
- pca006132 4y agoIf I remember correctly, ESP chips are not really power efficient comparing with other alternatives. And if you want to save power without sacrificing performance, you should do things like sleep and wait for interrupt.
- dividedbyzero 4y agoCan you recommend a more efficient alternative that is reasonably hobbyist-friendly?
- HuwytGreen 4y ago
- aulin 4y agoyou can, and probably should, program ESP8266 with the RTOS SDK and skip all the Arduino nonsense altogether.
- moolcool 4y agoWhat if OP is just a hobbyist who only knows Arduino and doesn't want to learn a whole new SDK just to toy around with microcontrollers in their spare time? I respect posts like this. They are fun and cool.
- HuwytGreen 4y agoIf you must use ESP8266 for some reason, then completely agreed. ESP8266 is obsolete now though, there are far more capable ESP32 variants, some of them specifically designed and marketed to replace the 8266 and to make transition as easily as possible. Not to mention the benefits of a now quite mature ESP-IDF SDK. Arduino is a great onramp to embedded, but it really needs an offramp.
- ilyt 4y agoThat's a very ignorant statement; they are still in production and entirely enough for many use cases, just like original arduinos are. They are also like $2 a pop for whole breakout board and less if you make actual device. I do agree if you just want to tinker the tiny extra for ESP32 is probably worth just for tinkerer but there is still a plenty of devices (in IOT space mostly) that are just "ESP8266 + some peripherals" and thus nice and hackable
- dragontamer 4y ago> just like original arduinos are. "Original" Arduino on the ATMega8 is fully obsolete and should be moved off of. Fortunately, it wasn't that popular. "Arduino Uno" (which popularized the Maker movement in 2010) with ATMega328 is also obsolete. You should use ATMega328pb at a minimum (but even then, the 328pb is nearly a decade old now...), or really the AVR DD chips that are cheaper, faster, simpler, more powerful. Ex: AVR64DD32 To explain how absurd it is... the AVR64DD32 uses 4.7mA at 24MHz fully active. In contrast, the old ATmega328 uses 12mA at 20MHz (its limit), and 3.5mA while idle (aka: 1st level of sleep). So an idle (1st sleep) ATmega328 uses basically the same power at a fully active AVR64DD32. Indeed, AVR64DD32 only uses 500uA (microAmps) at 4MHz fully active, so it can "busy loop" with less power than a sleeping ATmega328. AVR64DD32 costs $1.67 at lot size 1 from Digikey. ATmega328 costs $2.73 for lot size 1 from Digikey. ATmega328 comes with 32kB of Flash and 2kB of RAM. AVR64DD32 comes with 64kB of Flash and 8kB of RAM. It completely dominates the older chip in every possible regards. ------ Original Arduino Uno is still a great learning tool. But there have been over 10+ years of improvements to these chips. Anyone actually dipping down into AVR programming should prefer the newest chips. IMO, Arduino Uno should be seen as a learning tool. Fortunately, all of the stuff (ex: Assembly language, sleep modes, etc. etc.) still apply to the AVR64DD32. The peripherals have changed though... USART rather than UART. DAC included, OpAmps in AVR64DB32, etc. etc. Integrated dual-power supply on AVR DD chips (PortC can be on a 2nd voltage level, so its basically an integrated level-shifter). Full 24MHz speed at 1.8V (ATMega328 has this annoying "derating" curve, where 1.8V can only handle 4MHz). But no one should be using ATmega328 in new "serious" designs. Its just "still" useful because all of those old tutorials from 10 years ago still work today. So it has the most tutorials written for it, and should remain "steady" as a learning platform. But anyone taking the next step (learning the actual chip, learning how to solder, learning how to breadboard), needs to switch to the newest chips. The newest stuff is just cheaper, faster, and easier in practice. And still _mostly_ compatible with the old ATMega328 (same assembly language. A superset of the features. Similar concepts in layout / design, etc. etc)
- amelius 4y agoWhat is the simplest circuit to accurately measure power use?
- oddlama 4y agoJust a battery would be the simplest option. Just measure time until empty. If you want higher time resolution, there are several fully integrated hall effect current measurement ICs out there, like for example the ACS723. If you need even better accuracy or resolution and you can spare 100 bucks, just buy one of the Nordic Power Profiler Kits.
- ilyt 4y agoThat is the way. Once you get into actual measurement there is plenty of hard problems, like your device might only wake up for 10ms, take few hundred mAs of current and go to sleep.
- mungoman2 4y agoYou can place a small resistor in series with the supply, and measure the voltage drop over it. From this and using Ohm's law you can calculate the current. Then the power is trivial. There are special resistors for this purpose that are very low in resistance.
- amelius 4y ago
- tgtweak 4y agoThat's a pretty big difference. From less than a day on single 18650 to nearly 5 days.
- bxparks 4y agoThe ESP8266 has 5 sleep modes, as summarized by this README.md in the Arduino ESP8266 Core: https://github.com/esp8266/Arduino/tree/master/libraries/esp8266/examples/LowPowerDemo https://github.com/esp8266/Arduino/tree/master/libraries/esp... The `delay(1)` triggers the "Automatic Modem Sleep" 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. 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 "Forced Deep Sleep" 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. If the WiFi is needed only intermittently, the ESP8266 can be placed into "Forced Deep Sleep" 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 not support this (without hardware hacking), because it does not expose the GPIO16/D0 pin necessary to trigger the RESET. 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'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.
- antoniuschan99 4y agoYou can actually get the wifi state as low as 2 seconds in very ideal conditions. Average less than 4 seconds. If rssi is extremely low then it will def take longer. Yea the voltage regulator is very important and the ones on the nodemcu have very high quiecient current. Also on the top end you have to look for regulators that can handle the ~500mA peak current too. Otti Arc or Nordic PPk2 is an invaluable tool!
- em3rgent0rdr 4y agoThe Arduino IDE is very limiting. It hides a lot of these important implementation details in an attempt to keep things simple and easy to switch between Arduino-like devices (which is fine for users who aren't doing complex stuff or want all the features out of their particular chip or care much about optimization). I would instead recommend to use Espressif's SDK directly (https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/index.html https://docs.espressif.com/projects/esp8266-rtos-sdk/en/late...) so they have access to all the API the SDK offers.