Projects / Live Ohm's law plot

Live Ohm's law plot

Beginner2 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. UNOINA2190.78 A

    Wire the monitor

    VCC, GND, SDA to A4 and SCL to A5.

  2. UNO

    Wire the measurement path

    5V to VIN+, VIN- to a 1 kilohm resistor, resistor to GND.

  3. UNOINA2190.78 A

    Upload the sketch

    Serial monitor shows volts, milliamps and ohms.

  4. UNO

    Read the 1 kilohm result

    About 5 volts, 5 milliamps and 1000 ohms.

  5. UNO

    Swap in the 220 ohm resistor

    About 22 milliamps.

  6. UNO

    Swap in the 10 kilohm resistor

    About 0.5 milliamps.

  7. UNOINA2190.79 A

    Add the pot in series

    Turn it and record several voltage and current pairs.

  8. UNOINA2190.79 A

    Plot voltage against current

    The slope equals the resistance.

In short

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
See the electronics first. This build uses LED with a resistor. Try an LED with a resistor in the circuit builder and watch the voltages and currents before you wire it.

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Uno 5VINA219 VIN+Supply side of the shunt
INA219 VIN-One end of the test resistorLoad side of the shunt
Other end of the test resistorUno GNDCompletes the circuit
INA219 VCC and GNDUno 5V and GNDPower for the chip
INA219 SDAUno A4I2C data
INA219 SCLUno A5I2C 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.

CheckExpected
1 kilohm resistorAbout 5 mA and 1000 ohms
220 ohm resistorAbout 22 mA
10 kilohm resistorAbout 0.5 mA
No loadCurrent near 0
Two resistors in seriesResistances 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 →

Ask Lark AI

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.