Tap a part to see what it does.
Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.
Build it step by step
0 of 4 doneJoin the USB breakouts
VBUS through the INA219, grounds straight through.
I2C bus
INA219 and LCD both on A4 and A5.
Upload
Power the Uno from your computer.
Measure a gadget
Charge a phone for 10 minutes and note the mWh.
How do you build an USB energy meter?
An INA219 between two USB-C breakouts measures volts, milliamps and the total milliwatt-hours a USB gadget uses, shown live on a 1602 LCD. You need Arduino Uno R3, INA219 Current Monitor, 1602 Character LCD, USB-C Breakout Board × 2 and Breadboard 830 Tie Points. It takes 4 steps and about 45 minutes.
- Level
- Beginner
- Time
- About 45 min
- Parts
- 5
Wiring
| From | To | Why |
|---|---|---|
| USB-C in VBUS | INA219 VIN+ | 5 V from the charger |
| INA219 VIN− | USB-C out VBUS | To the gadget |
| Both USB GND | Uno GND | Shared ground |
| INA219 and LCD SDA / SCL | Uno A4 / A5 | Same I2C bus (0x40 and 0x27) |
Code
Libraries: Adafruit INA219 and LiquidCrystal I2C. The usual 0.1 Ω shunt reads up to about 3.2 A, enough for most USB gadgets. 1 kWh = 1,000,000 mWh.
Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <Adafruit_INA219.h>
#include <LiquidCrystal_I2C.h>
Adafruit_INA219 ina;
LiquidCrystal_I2C lcd(0x27, 16, 2);
double mWh = 0; unsigned long last;
void setup() { ina.begin(); lcd.init(); lcd.backlight(); last = millis(); }
void loop() {
float v = ina.getBusVoltage_V(), mA = ina.getCurrent_mA();
unsigned long now = millis();
mWh += v * mA * (now - last) / 3600000.0;
last = now;
lcd.setCursor(0, 0); lcd.print(v, 2); lcd.print("V "); lcd.print(mA, 0); lcd.print("mA ");
lcd.setCursor(0, 1); lcd.print(mWh, 1); lcd.print(" mWh ");
delay(250);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Nothing plugged in | About 0 mA |
| Small fan or LED lamp | Steady current, mWh rising |
| Phone charging | Several hundred mA at about 5 V (fast-charge chargers may stay at 5 V without data lines) |
If it does not work
Gadget does not charge
The charger needs the CC resistors on the breakout, and fast charging needs D+ and D−.
Negative mA
VIN+ and VIN− swapped.
LCD shows blocks
Turn the contrast trimmer.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the USB energy meter?
Arduino Uno R3, INA219 Current Monitor, 1602 Character LCD, USB-C Breakout Board × 2 and Breadboard 830 Tie Points. 1602 Character LCD: With the I2C backpack. USB-C Breakout Board × 2: One in from the charger, one out to the gadget.
How long does the USB energy meter take to build?
About 45 minutes for a beginner maker, in 4 steps.
How do I know the USB energy meter works?
Nothing plugged in: About 0 mA. Small fan or LED lamp: Steady current, mWh rising. Phone charging: Several hundred mA at about 5 V (fast-charge chargers may stay at 5 V without data lines).
Gadget does not charge: what should I check?
The charger needs the CC resistors on the breakout, and fast charging needs D+ and D−.
Negative mA: what should I check?
VIN+ and VIN− swapped.
LCD shows blocks: what should I check?
Turn the contrast trimmer.
