Build a Power Meter with ESPHome and INA219

3 min readOct 18, 2022


EasyPowew — a simple power meter

Recently, I was using ESP32 to make some small things, one of the devices is battery-powered, so I am concerned about the battery life, but I don’t have a suitable electronic load meter on hand, so when I was going through the module inventory, I just found an INA219 module, so I took it to make a power meter directly.

With a 12864 OLED screen, it is possible to observe the real-time power and power consumption of the microcontroller device in real time.

Measure power of ESP32 with LED


ESPHome is a configured system for generating ESP32/ESP8266 smart home firmware, which is generally used as a system in smart home nodes to use with very cheap ESP32/ESP8266 modules.

When checking the modules it supports, I found that INA219 is also among them, and ESPHome itself has good support for 12864 OLED, so I finally chose ESPHome directly as the base system of the power meter, which can save writing a lot of basic codes, such as task schedule, screen drawing, I2C bus reading and writing, etc., and only need to focus on the core power meter function can be.

Recently, I have also used ESPHome, and found that it has many advantages, and can be used as a basic application framework for Arduino projects.

  • Configurable code generation, no need to manage complex library dependencies
  • Rich module library support, for the development of MCU projects, common input and output modules are built-in support
  • Complete app runtime framework, developers only need to focus on the business itself, other related content is built in, such as MQTT, OTA and other features
  • Flexible Lambda support, its Lambda is the C++ Lambda, so for experienced developers, you can write code directly

Overall, for general DIY projects, ESPHome is powerful and flexible enough to handle most needs.


INA219 is a power monitoring chip from Texas Instruments.

The INA219 is a current shunt and power monitor with an I2C- or SMBUS-compatible interface. The device monitors both shunt voltage drop and bus supply voltage, with programmable conversion times and filtering.

Features of INA219:

  • Senses Bus Voltages from 0 to 26 V
  • Reports Current, Voltage, and Power
  • 16 Programmable Addresses
  • High Accuracy: 0.5% (Maximum) Over
    Temperature (INA219B)

For general MCU chips, the power supply is 5V or 3.3V, and the range of Li-ion battery power supply is 3V~4.2V, so the measurement range of INA219 is enough to use, and the 0.5% accuracy is enough to measure the expected range of data during use.

Data Monitor

For monitoring the data, I found an App MQTT Explorer directly on the App Store that displays the values in the MQTT Topic messages directly as graphs, so it’s easy to observe the changes in power and consumption throughout the device’s operation.

Monitor power with MQTT Explorer

Open Source Project

This power meter is simple, you can just use ESP8266 + INA219 module + 12864 OLED on a PCB peg board with jumpwires connected, plug in USB and start using it directly.

For the code, please go to GitHub:

That’s all, thanks for reading.




Coding and creating, build apps on