Skip to content

DanielRossi1/EdgePowerMeter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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 graphs
  • πŸš€ OpenGL accelerated rendering for smooth 60+ FPS
  • πŸ“ˆ Live statistics with min/max/average values
  • πŸ’Ύ CSV data export with full measurement history
  • πŸ“‚ CSV import to reload and re-analyze data
  • πŸ“„ Professional PDF report with graphs included
  • πŸ“‰ FFT spectrum analysis for current signal (optional in PDF)
  • 🎨 Dark and Light theme support
  • βš™οΈ Persistent settings - preferences saved automatically
  • πŸ”Œ Auto-reconnect with OS event-based port monitoring
  • πŸ” Zoom and pan on X-axis (Y-axis auto-scales)
  • πŸ–±οΈ Cursor values on hover with crosshair
  • πŸ“ Selection region for detailed analysis
  • ⏱️ Time-based scrolling window (configurable)

πŸ–₯️ Desktop Application

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

Main Interface

EdgePowerMeter GUI

The main window displays three synchronized graphs showing:

  • Voltage (V) - Blue trace
  • Current (mA) - Orange trace
  • Power (mW) - Green trace

Statistics Panel

Real-time statistics are displayed in dedicated cards:

Statistics Summary

Each measurement type shows:

  • Minimum value
  • Maximum value
  • Average value
  • Total energy consumed (Wh)

Derived Metrics

Derived Metrics

Advanced calculations including:

  • Sampling rate (Hz)
  • Voltage/Current ripple
  • Power factor estimation
  • Load impedance estimation

Data Export

Export Options

Export your data in multiple formats:

  • CSV: Full measurement history with timestamps
  • PDF: Professional report with statistics summary

Export Summary


🧩 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

# Install Python dependencies
pip install PySide6 pyqtgraph pyserial reportlab matplotlib numpy

# Optional: Install PyOpenGL for GPU-accelerated rendering
pip install PyOpenGL PyOpenGL_accelerate

# Run the application
python run.py

Firmware

Arduino IDE

  1. Install ESP32 board support
  2. Install required libraries:
    • INA226 by Rob Tillaart
    • Adafruit_GFX
    • Adafruit_SSD1306
    • RTClib by Adafruit
  3. Open firmware/firmware.ino
  4. Select board: ESP32C3 Dev Module
  5. Upload

Arduino CLI

# Compile
arduino-cli compile --fqbn esp32:esp32:esp32c3 firmware

# Upload
arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:esp32c3 firmware

PlatformIO

pio run --target upload

πŸ”¨ 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

The firmware outputs CSV data at 921600 baud with millisecond-precision timestamps:

Timestamp,Voltage[V],Current[A],Power[W]
2025-11-30 12:34:56.123,5.0123,0.2500,1.2531
2025-11-30 12:34:56.223,5.0118,0.2498,1.2525

The timestamp uses the DS3231 RTC with SQW sync for Β±2ppm accuracy.

Reading Serial Data (Linux)

# Using screen
screen /dev/ttyUSB0 921600

# Using cat
stty -F /dev/ttyUSB0 921600 && cat /dev/ttyUSB0

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

Firmware Settings

Key configuration in firmware/firmware.ino:

namespace Config {
    constexpr float SHUNT_RESISTANCE = 0.010f;      // Ohms
    constexpr float CURRENT_LSB_MA = 0.100f;        // mA resolution
    constexpr uint16_t INA226_AVERAGING = 16;       // Samples averaged
    constexpr uint32_t MEASUREMENT_INTERVAL = 10;   // ms between readings
    constexpr uint32_t SERIAL_BAUD = 921600;        // High-speed serial
}

RTC Synchronization

Set FORCE_RTC_UPDATE = true in firmware to sync RTC with compile time on first boot.


πŸ“Š Specifications

Parameter Value
Voltage Range 0 - 36V
Current Range Β±3.2A (with 0.01Ξ© shunt)
Resolution 1.25mV / 0.1mA
Sampling Rate ~100 Hz
Serial Baud 921600
Display Update 100ms

πŸ“ Project Structure

EdgePowerMeter/
β”œβ”€β”€ firmware/               # Arduino firmware folder
β”‚   β”œβ”€β”€ firmware.ino        # Main firmware sketch
β”‚   β”œβ”€β”€ PrecisionTime.h/cpp # Millisecond-precision timing library
β”‚   └── OLEDStatus.h/cpp    # OLED display library
β”œβ”€β”€ run.py                  # Application entry point
β”œβ”€β”€ build.py                # Build script for executables
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ main.py             # Application bootstrap
β”‚   β”œβ”€β”€ version.py          # Version info
β”‚   β”œβ”€β”€ serial/
β”‚   β”‚   └── reader.py       # Serial communication
β”‚   └── ui/
β”‚       β”œβ”€β”€ main_window.py  # Main GUI
β”‚       β”œβ”€β”€ theme.py        # Dark/Light themes
β”‚       β”œβ”€β”€ settings.py     # Settings dialog
β”‚       β”œβ”€β”€ report.py       # PDF/CSV export & import
β”‚       └── widgets/        # Reusable UI components
β”‚           β”œβ”€β”€ plot_widget.py
β”‚           β”œβ”€β”€ plot_buffers.py
β”‚           β”œβ”€β”€ stat_card.py
β”‚           └── port_discovery.py
β”œβ”€β”€ assets/
β”‚   └── prototype/          # Screenshots and photos
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ BUILD.md            # Build instructions
β”‚   β”œβ”€β”€ HARDWARE.md         # Hardware documentation
β”‚   └── SOFTWARE.md         # Software documentation
β”œβ”€β”€ 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

License

Stars

Watchers

Forks

Packages

No packages published