Build it step by step
0 of 8 doneWire the monitor
VCC, GND, SDA to A4 and SCL to A5.
Wire the measurement path
5V to VIN+, VIN- to a 1 kilohm resistor, resistor to GND.
Upload the sketch
Serial monitor shows volts, milliamps and ohms.
Read the 1 kilohm result
About 5 volts, 5 milliamps and 1000 ohms.
Swap in the 220 ohm resistor
About 22 milliamps.
Swap in the 10 kilohm resistor
About 0.5 milliamps.
Add the pot in series
Turn it and record several voltage and current pairs.
Plot voltage against current
The slope equals the resistance.
How do you build a live Ohm's law plot?
A current monitor shows voltage and current for several resistors and plots the straight line. You need Arduino Uno R3, INA219 Current Monitor, Resistor 220 Ω, Resistor 1 kΩ, Resistor 10 kΩ, Potentiometer 10 kΩ and Breadboard 830 Tie Points. It takes 8 steps and about 120 minutes.
- Level
- Beginner
- Time
- About 120 min
- Parts
- 7
Parts list
- Development BoardsBuyArduino Uno R3 × 1
- SensorsBuy
- PassivesBuyResistor 220 Ω × 1
- PassivesBuyResistor 1 kΩ × 1
- PassivesBuyResistor 10 kΩ × 1
- PassivesBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Uno 5V | INA219 VIN+ | Supply side of the shunt |
| INA219 VIN- | One end of the test resistor | Load side of the shunt |
| Other end of the test resistor | Uno GND | Completes the circuit |
| INA219 VCC and GND | Uno 5V and GND | Power for the chip |
| INA219 SDA | Uno A4 | I2C data |
| INA219 SCL | Uno A5 | I2C clock |
Code
Ohm's law says the current through a resistor is the voltage across it divided by its resistance. The INA219 measures both at once: it reads the voltage on the load side of its tiny shunt resistor and the small voltage across the shunt, which it turns into a current. With 5 volts across 220 ohms the current is about 22 milliamps; across 1 kilohm it is about 5 milliamps; across 10 kilohms about 0.5 milliamps. The sketch averages twenty readings and prints volts, milliamps and the ratio, so you can see the resistance appear from the two measurements and compare it with the colour code. To plot a straight line, change the voltage rather than the resistor: put the pot in series with the 1 kilohm resistor, or use a bench supply, and record several pairs of voltage and current. The slope of voltage against current is the resistance. Keep the test current low; the Uno's 5 volt pin is fine for these values. Real resistors are 1 to 5 percent off their labels, so the results will be close but not exact.
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 <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina;
void setup() {
Serial.begin(9600);
while (!Serial) {}
if (!ina.begin()) {
Serial.println("INA219 not found. Check SDA, SCL and power.");
while (true) {}
}
Serial.println("volts,milliamps,ohms"); // column names for the serial plotter or a spreadsheet
}
void loop() {
float v = 0, i = 0;
const int N = 20;
for (int k = 0; k < N; k++) { // average to reduce noise
v += ina.getBusVoltage_V();
i += ina.getCurrent_mA();
delay(10);
}
v /= N; i /= N;
float r = (i > 0.05) ? (v * 1000.0 / i) : 0; // R = V / I, with current in milliamps
Serial.print(v, 3); Serial.print(',');
Serial.print(i, 2); Serial.print(',');
Serial.println(r, 1);
delay(500);
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
volts,milliamps,ohms 4.980,119.99,41.5 4.981,119.99,41.5 4.979,120.01,41.5 4.980,120.00,41.5 4.979,119.97,41.5
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| 1 kilohm resistor | About 5 mA and 1000 ohms |
| 220 ohm resistor | About 22 mA |
| 10 kilohm resistor | About 0.5 mA |
| No load | Current near 0 |
| Two resistors in series | Resistances add |
If it does not work
INA219 not found
Check SDA, SCL, power and the address.
Current reads negative
VIN+ and VIN- are swapped.
Noisy reading at 10 kilohm
Small currents are near the chip's limit, use a larger sample.
Resistance far off
Check the resistor colour bands.
Readings jump
A loose breadboard contact, press the parts in.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the live Ohm's law plot?
Arduino Uno R3, INA219 Current Monitor, Resistor 220 Ω, Resistor 1 kΩ, Resistor 10 kΩ, Potentiometer 10 kΩ and Breadboard 830 Tie Points.
How long does the live Ohm's law plot take to build?
About 120 minutes for a beginner maker, in 8 steps.
How do I know the live Ohm's law plot works?
1 kilohm resistor: About 5 mA and 1000 ohms. 220 ohm resistor: About 22 mA. 10 kilohm resistor: About 0.5 mA.
INA219 not found: what should I check?
Check SDA, SCL, power and the address.
Current reads negative: what should I check?
VIN+ and VIN- are swapped.
Noisy reading at 10 kilohm: what should I check?
Small currents are near the chip's limit, use a larger sample.
Resistance far off: what should I check?
Check the resistor colour bands.
