Skip to content

About

Measure power consumption of your edge devices without Voltage Throttling!

Topics

Resources

Stars

10 stars

Watchers

0 watching

Forks

Repository files navigation

EdgePowerMeter ⚡

EdgePowerMeter Hardware

A precision power monitoring system for embedded AI workloads

License Platform Python


📋 Table of Contents


🔎 Overview

EdgePowerMeter is a complete power monitoring solution designed to measure voltage, current, and power consumption of embedded devices running AI inference workloads. Perfect for benchmarking FPS-per-Watt (FPS/W) efficiency of machine learning models at the edge.

Why EdgePowerMeter?

  • Precision Measurements: INA226 power monitor with configurable averaging
  • Real-time Visualization: Modern desktop app with live graphs
  • Data Export: CSV and PDF report generation
  • Timestamped Logs: DS3231 RTC for accurate time synchronization
  • Open Source: Full hardware schematics and software included

✨ Features

Hardware

  • 🔋 INA226 high-precision power monitor (I²C)
  • 🕐 DS3231 real-time clock for accurate timestamps
  • 📺 SSD1306 OLED display (128×32) for live readings
  • ⚡ ESP32-C3 microcontroller with WiFi/BLE capability
  • 🔧 0.01Ω shunt resistor for current sensing

Software

  • 📊 Real-time voltage, current and power plots with peak-preserving decimation (smooth even after hours at ~1 kHz)
  • ⏱️ Device-clock time base (firmware 2.x): sample spacing, energy and spectrum are not distorted by USB/PC latency
  • 🧮 Lost-sample detection (sequence numbers) and real-time energy, charge, min/max and average power
  • 🎛️ Remote sensor configuration: INA226 averaging and conversion times, presets from ~2 Hz to ~900 Hz, saved on the device
  • 🕐 Clock sync of the DS3231 with the PC, with live device–PC offset
  • 🎯 Calibration in the app: shunt value, current zero ("zero now"), voltage/current gain and offset
  • 📐 Analysis page: selectable range, per-quantity statistics, power supply quality (ripple, noise, load regulation, settling time) and frequency spectrum
  • 🚩 Markers: press M (or right-click the plot) to mark events; every segment between markers gets duration, energy, average and peak power
  • 🏁 Benchmark mode: energy per inference, inferences per joule and FPS/W, also net of the idle power
  • 💽 Continuous recording: every acquisition is saved while it runs to a visible CSV file (crash-safe, no duplicates, no hidden files)
  • 💾 CSV export/import (decimal comma, date/time or Unix time) and PDF reports with vector charts
  • 🌍 5 languages (English, Italiano, Español, Français, Deutsch), automatically selected from the system, translated offline with a local model
  • 🎨 Dark, light or system theme, configurable units, digits, refresh rate, time window and more
  • 🔌 Safe auto-reconnect: after an unplug the recording continues; a manual Stop never restarts it
  • ⌨️ Keyboard shortcuts (Ctrl+R, Ctrl+O, Ctrl+E, Ctrl+P, Ctrl+1…5)

🖥️ Desktop Application

The EdgePowerMeter desktop application provides a modern interface for real-time power monitoring and data analysis.

The window has a navigation rail with five pages: Live, Analysis, Device, Settings and About (Ctrl+1…5).

The screenshots show simulated demo data (idle → model load → inference at 10 FPS on a ~5 V rail); the Device page is taken from a real sensor.

Live

Live page

Three synchronized plots (voltage, current, power) with value tiles and running totals: energy, charge, peak power, duration, sample rate and lost samples. Drag the plots to look back and use the mouse wheel to change the time window; Follow live returns to the latest data. Press M (or the Marker button, or right-click a plot) to mark an event. Every acquisition is written to a CSV file while it runs, as shown in the status bar.

Analysis

Analysis page

Drag the highlighted region to select the range to analyze (or Select all), then switch between the tabs below the plot. Statistics gives duration, energy, charge, average power and current RMS of the selection plus min, max, average, standard deviation and peak-to-peak of each quantity.

Markers turns the marks into segments, each with its start, duration, average and peak power, energy and charge; click a row to select that segment.

Markers tab

Benchmark computes energy per inference, inferences per joule and throughput per watt (FPS/W) for the selection or a segment, also net of the idle power measured in another segment, and can add them to the PDF report.

Benchmark tab

Spectrum shows where the load variation energy is concentrated (periodic bursts, throttling cycles, regulator ripple) with the dominant frequencies; Power supply quality rates the supply rail: voltage range, ripple, RMS noise, load regulation and settling time.

Spectrum tab

Export CSV and Export PDF work on the selection or the whole recording; PDF reports include vector charts, statistics, markers, supply quality, spectrum and benchmark results.

Device

Device page

Connection and firmware details, clock synchronization of the DS3231 with the PC, INA226 averaging and conversion times (with presets from ~2 Hz to ~900 Hz, applied immediately and optionally saved on the device) and calibration of shunt value, current zero, gain and offset. Remote configuration and clock sync need firmware 2.x.

Settings

Settings page

Language, theme, plot refresh rate and time window, line width, grid, units, significant digits, average-power mode, hardware acceleration and acquisition options.


🧩 Hardware

Components

Component Model I²C Address Description
MCU ESP32-C3 SuperMini - Main microcontroller
Power Monitor INA226 0x40 Voltage/Current sensing
Display SSD1306 0x3C 128×32 OLED
RTC DS3231 0x68 Real-time clock
Shunt R2512 - 0.01Ω current sense

Project Files

File Description
Manufacture/BOM.csv Bill of Materials
Manufacture/PickAndPlace.csv Pick and Place coordinates
Schematics/EdgePowerMeter.fzz Fritzing schematic
Schematics/EdgePowerMeter_bom.csv Schematic BOM
firmware/firmware.ino Arduino firmware with libraries

Wiring Overview

All I²C devices share a common bus:

  • SDA: GPIO8 (ESP32-C3)
  • SCL: GPIO9 (ESP32-C3)
  • VCC: 3.3V common rail
  • GND: Common ground

The INA226 monitors voltage across the shunt resistor via VIN+ (high side) and VIN- (low side).


📦 Installation

Pre-built Binaries

Download the latest release for your platform from the Releases page:

Platform File
Linux (Snap Store) sudo snap install edgepowermeter
Linux (Debian/Ubuntu) edgepowermeter_x.x.x_amd64.deb
Linux (Other) EdgePowerMeter (standalone)
Windows EdgePowerMeter.exe
macOS (Intel) EdgePowerMeter-macos-x86_64.zip
macOS (Apple Silicon) EdgePowerMeter-macos-arm64.zip

Linux (Snap Store) - Recommended

sudo snap install edgepowermeter
sudo snap connect edgepowermeter:raw-usb  # Required for USB serial access
edgepowermeter

Linux (.deb)

sudo dpkg -i edgepowermeter_1.0.0_amd64.deb
edgepowermeter

Linux (standalone)

chmod +x EdgePowerMeter
./EdgePowerMeter

From Source

# Clone the repository
git clone https://github.com/DanielRossi1/EdgePowerMeter.git
cd EdgePowerMeter

# Create a virtual environment and install the app with its dependencies
python3 -m venv .venv
.venv/bin/pip install -e .          # PySide6, pyqtgraph, pyserial, reportlab, numpy, PyOpenGL

# Run the application
.venv/bin/python run.py

Firmware

Arduino IDE

  1. Install ESP32 board support
  2. Install required libraries:
    • Adafruit_GFX
    • Adafruit_SSD1306
    • RTClib by Adafruit (the Rob Tillaart INA226 library is no longer needed since firmware 2.0)
  3. Open firmware/firmware.ino
  4. Select board ESP32C3 Dev Module and set USB CDC On Boot: Enabled
  5. Upload

Arduino CLI

arduino-cli compile --fqbn esp32:esp32:esp32c3:CDCOnBoot=cdc firmware
arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32c3:CDCOnBoot=cdc firmware

The desktop app also works with firmware 1.x, but device time, lost-sample detection, sensor configuration and clock sync require firmware 2.x.


🔨 Building

To build standalone executables for distribution:

# Install build dependencies
pip install pyinstaller

# Build executable + .deb package (Linux)
python build.py all

# Or just the executable
python build.py exe

Output files are created in dist/:

  • EdgePowerMeter - Standalone executable
  • edgepowermeter_1.0.0_amd64.deb - Debian package

📖 See docs/BUILD.md for detailed build instructions, including:

  • Building on Windows and macOS
  • Creating installers
  • CI/CD integration
  • Troubleshooting

🚀 Usage

Quick Start

  1. Connect hardware to your computer via USB
  2. Launch the app: python run.py or run the executable
  3. Select serial port from the dropdown
  4. Click Start to begin recording

Serial Output Format

At boot the firmware prints human-readable CSV (also what firmware 1.x sends), so it can be used with any serial monitor:

Timestamp,Voltage[V],Current[A],Power[W]
2026-10-08 12:34:56.123,5.01250,0.250000,1.253125

The desktop app performs a handshake and switches the device to a compact RAW format with device time in µs, a sequence number and the raw INA226 registers. See docs/PROTOCOL.md for the full protocol and the command set (HELLO, GET, SET AVG/VCT/ICT/OLED/STREAM/SHUNT, SYNC, SAVE).

Reading Serial Data (Linux)

screen /dev/ttyACM0 2000000

Calculating FPS per Watt

FPS/W = Inference_FPS / Average_Power_W

Example: 30 FPS inference with 2.5W average = 12 FPS/W


⚠️ Safety Warning

⚠️ IMPORTANT: This project involves electrical connections. Incorrect wiring can cause damage, fire, or injury.

Precautions

  • ❌ NOT designed for AC voltages
  • 🔌 Disconnect power before changing connections
  • 🔍 Verify polarity with a multimeter before powering
  • ⚡ Use appropriate fuses for your application
  • 💧 Keep device dry and away from conductive materials
  • 👨‍🔧 Seek professional help if unsure

The author assumes no responsibility for damage or injury resulting from improper use.


🛠️ Configuration

Sensor and Calibration

With firmware 2.x, averaging and conversion times are set from the Device page of the app (or with serial commands) and can be stored on the device with Save as device default. Calibration (shunt value, zero offset, gain) is applied by the app, so no reflashing is needed.

RTC Synchronization

Use Sync clock with PC on the Device page (or enable automatic sync on connect). FORCE_RTC_UPDATE = true in the firmware still forces a one-time sync to the compile time.


📊 Specifications

Parameter Value
Voltage Range 0 - 36V
Current Range ±3.2A (with 0.01Ω shunt)
Resolution 1.25 mV / 0.25 mA (2.5 µV shunt LSB)
Sampling Rate ~2 Hz – ~900 Hz (configurable, default ~893 Hz)
Time Stamping Device µs clock, anchored to the DS3231 SQW (±2 ppm)
Serial Native USB-CDC (2000000 baud nominal)
Display Update 4 Hz (non-blocking)

📁 Project Structure

EdgePowerMeter/
├── firmware/                 # ESP32-C3 firmware (Arduino sketch)
│   ├── firmware.ino          # Sampling loop, protocol, commands
│   ├── INA226Lite.h/cpp      # Minimal INA226 driver
│   ├── PrecisionTime.h/cpp   # DS3231 SQW time anchors
│   └── OLEDStatus.h/cpp      # Non-blocking OLED display
├── app/
│   ├── main.py               # Bootstrap (GPU preflight, QApplication)
│   ├── core/                 # Samples store, statistics, PSU quality, spectrum, settings
│   ├── serial/               # Port I/O, protocol decoder, reader thread
│   ├── export/               # CSV import/export, PDF report, unit formatting
│   ├── i18n/                 # Runtime translations + generated catalogs
│   └── ui/                   # Main window, controller, pages, widgets, theme
├── tools/i18n/               # Offline machine-translation tool
├── tests/                    # pytest suite (headless, fake device)
├── docs/                     # BUILD, HARDWARE, SOFTWARE, PROTOCOL
├── Manufacture/              # PCB production files
└── Schematics/               # Circuit diagrams

🤝 Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

TODO

  • 3D printed enclosure design
  • Mobile app companion
  • Data logging to SD card
  • Improved PCB design

📜 License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.


Made with ❤️ for the embedded AI community

⭐ Star this repo if you find it useful!

About

Measure power consumption of your edge devices without Voltage Throttling!

Topics

Resources

Stars

10 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages