ESP8266: Monitoring Power Consumption

Summary of ESP8266: Monitoring Power Consumption


This article explains how to monitor power consumption in battery-driven ESP8266/ESP32 devices to optimize code for extended battery life. It contrasts server-side development with embedded constraints, emphasizing that reliable measurements are essential before tuning performance. The author advocates writing readable code first, then optimizing specific areas like sleep cycles based on data. While the text mentions the ESPaper project as a focus, it does not list specific hardware parts or components used in the setup.

Parts used in the ESPaper:

  • ESP8266
  • ESP32
  • Battery
  • Power monitoring tool

In this post I’m going to show you how you can monitor the power consumption of your battery driven (ESP8266/ ESP32) device. Measuring the power consumption over a full activity/ sleep cycle is the precondition to optimize your code for a longer battery runtime. Only with a reliable tool you can decide which code changes lead to less consumption. In a later post we’ll look at some tweaks we can apply to the code to get a few more days out of the battery.

ESP8266 Monitoring Power Consumption

As a long time professional Java developer I’m used to write applications that run on servers with lots of resources: RAM, disk space and energy consumption are rarely a limiting factor for the software we write. Developing software for embedded devices is a totally different story: memory both for flash and heap is very limited. And if you want to run your device from battery every second you are staying online counts towards the total energy bill of your battery. In our big server applications we usually say that you should first write reliable and readable code.

If your application is not fast enough or consumes too much memory you start tuning the hot spots of your code until you get the desired results. Of course, it’s really hard to turn a bad decision in your architecture into a fast performing application. I would say that these rules are also true for embedded devices: first write reliable and readable code, then start tuning. And avoid costly dead ends which are later hard to fix.

In my opinion you can’t tune a system if you don’t have reliable measurements before and after you change any factor. So how do you collect this information in an embedded device? That of course depends on what aspect you would like to improve: memory, battery runtime, connection speed, etc. In this post I’m interested in prolonging the battery life of the ESPaper.

Read more: ESP8266: Monitoring Power Consumption

Quick Solutions to Questions related to ESPaper:

  • Why is measuring power consumption important?
    It is the precondition to optimize code for a longer battery runtime and decide which changes lead to less consumption.
  • What is the difference between server and embedded development?
    Servers have abundant RAM, disk space, and energy, while embedded devices have limited memory and every second online counts towards the energy bill.
  • What is the recommended order for coding on embedded devices?
    First write reliable and readable code, then start tuning the hot spots.
  • Can you tune a system without measurements?
    No, you cannot tune a system if you do not have reliable measurements before and after changing any factor.
  • What aspect is the author interested in improving in this post?
    The author is interested in prolonging the battery life of the ESPaper.
  • What determines the total energy bill of a battery?
    Every second the device stays online counts towards the total energy bill of your battery.
  • Is it easy to fix bad architectural decisions later?
    No, it is really hard to turn a bad decision in your architecture into a fast performing application.
  • What will be covered in a later post?
    A later post will look at some tweaks we can apply to the code to get a few more days out of the battery.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter