DC power monitor (INA219) Measures voltage, current and power of a 12–24 V line, ideal for a solar panel, power station or LED strip. Includes a web page and OLED.
Level: Beginner Board: ESP32 DevKit V1 (WROOM-32) Power & blackouts
⚠ Safety Check the polarity: a reversed battery will destroy the module.
What you need Buy the parts kit · Estimated total: $10.00
ESP32 DevKit V1 (30 pin, WROOM-32) × 1
$4.00
INA219 current/voltage sensor module × 1
$2.00
OLED 0.96" 128x64 I2C SSD1306 × 1
$2.50
Dupont jumper wires (M-F, M-M) × 1
$1.50
Some links are affiliate links: we may earn a commission at no extra cost to you.
Libraries Arduino IDE → Tools → Manage Libraries, then install:
Adafruit INA219 Adafruit SSD1306 Adafruit GFX Code dc-power-monitor.ino Copy Download .ino
#include <Wire.h>
#include <Adafruit_INA219.h>
#include <Adafruit_SSD1306.h>
Adafruit_INA219 ina;
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
double wh = 0; uint32_t last = 0;
void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
ina.begin();
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
last = millis();
}
void loop() {
float v = ina.getBusVoltage_V(), a = ina.getCurrent_mA() / 1000.0, w = v * a;
uint32_t now = millis(); wh += w * (now - last) / 3600000.0; last = now;
oled.clearDisplay(); oled.setTextColor(WHITE); oled.setTextSize(2);
oled.setCursor(0, 0); oled.printf("%.2f V", v);
oled.setCursor(0, 20); oled.printf("%.3f A", a);
oled.setCursor(0, 40); oled.printf("%.1fW %.2fWh", w, wh);
oled.display();
delay(500);
}Flash a ready firmware from the browser Paste your error into the AI Error Doctor
Build tips The module handles up to 26 V and 3.2 A; use an external shunt for more current. Place the INA219 on the positive (high) side of the load. ← ← All projects
Related ideas ⚠ Caution Batteries: watch polarity, use protected cells and a charger with protection, never charge damaged cells unattended.
Watches the battery of a 12 V mini-UPS that powers the router, shows its voltage, load and estimated runtime, and warns before it runs flat.
⛔ High risk High-current battery: a short circuit can start a fire. Put a fuse next to the battery plus, use thick enough wires and respect the BMS limits.
Shows voltage, current and power of a battery bank (INA219) so you know the real charge and load during outages.
⛔ High risk Mains 220–230 V can kill. Work with the power off, use certified isolated modules in an enclosure, fuse the line, and ask a qualified electrician if you are not sure.
Watches the inverter / battery current and switches off non-critical loads with a relay when the battery runs low.
Comments
No comments yet. Share your experience or ask a question.