Monthly Archives:July 2021

Remote Power monitor

29 Jul 21
No Comments

I recently had the problem that I wanted to measure the power consumption of my weather sensor under real life conditions. Fundamental question here: Can a solar cell with an attached Lipo and an BMS supply enough energy so that the sensor can run “infinitely” without externally supplied power.

In order to measure this I needed a device able to measure power (implicitly also voltage and current) being operated remotely (potentially anywhere).

To measure Power/Voltage/Current I recently used an INA219A in another project (I8Driver) and was quite satisfied withit. To control the INA’s I decided for an ESP32 (since I have a lot of experience with it)

For programming the ESP32 I decided to integrate a USB connector that can also supply the powermeter with power. For the USB to TTL I do with CH340C Chips. Less pins that an FT232. I have good experience with it.

Programming the ESP requires a control of the reset pin (EN) and the Flash Pin (Gpio 0 ) of the ESP32. Luckyly platformIO by default handles it nicely with UART interface. It controls the RTS and DTR signals in the correct way to be used as RTS= Reset and DTR as Flash. Both are active Low, so a pullup resistor (10k) ensures that the pins are in a defined state. In typical ESP32 Boards of the shelf the control of reset and flash is a bit more complicated and requires additional transistors since the boards have buttons for a manual interaction. Since my solution does not have reset or flash buttons, there is no need for it.

In case there is enough power (Landline) for the remote powermeeter it might be nice to have a display so I integrated an 0.98″ OLED

After the first prototype it turned out that a button to be able to enter a maintenance mode is very useful. So is an LED in case the OLED is not used due to power limitations.

In the end I came up with the following design

Here some pictures



Regarding the software:

WiFi Handling

The Power Mon is configured via WiFi. It can operate in station mode (creating its own accesspoint) or it can attach itself to an existing WiFi router (if configured accordingly).

Configuration is done via simple HTTP GET requests providing the parameters as query parameters.

This example defines the wifi connetion for a WiFi router. If the power mon is in accesspoint mode, the IP to use is

Destination for measurement results

Power mon measures values in intervalls. The results can be transferred to the following destinations:

MQTT Server

Via the WiFi config a MQTT server (Host, port, user/password (optional) and SSL (optional) can be configured. If the MQTT server is configured and the ESP32 is able to reach an exiting WiFi network(router), it will publish its measurements to the MQTT server

REST(ish) Server

Optionally a RESTish server can be configured. In this case the ESP32 will issue GET requests with query params to the configured server if the ESP32 was able to connect to a WiFi router. The REST afficionados will state that it is not REST since the request is GET and not POST, but the implementation of GET is just easier and we are in an embedded environment.


In case the Power Mon has no connection to any server, the measurements can be stored locally in the Flash Mem of the ESP32 (SPIFFS).

Deep Sleep

The Power mon can be set into deep sleep between its measurement intervall. This lowers the energy consumption of it.

Maintenance Mode

In its regular routing there might be conditions that Power Mon cannot be reached via WiFi ( if only Local measurement storage is wanted). In order to bring Power Mon into a state where it can be configured, the maintenance button exists.

Pressing the button while booting up brings Power mon into Maintnance mode. It does not do any mesurements then. Only Wifi ist started and it tries to reach a configured access point.