Projects / Solar panel I-V curve tracer

Solar panel I-V curve tracer

Intermediate3 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. ESP32INA219SOLAR0.24 A

    Wire the INA219

    In series with the panel plus.

  2. ESP32IRLZ44

    Build the load

    MOSFET and 10 ohm sense resistor.

  3. ESP32LM35821.7°C

    Add the op-amp

    Gate driver from the DAC.

  4. ESP32INA2190.24 A

    Test with a bench supply

    Check the current follows the DAC.

  5. ESP32SOLAR

    Connect the panel

    Outdoors in sun.

  6. ESP32

    Run a sweep

    Copy the CSV to a spreadsheet.

  7. ESP32

    Plot I-V and P-V

    Mark the maximum point.

In short

How do you build a solar panel I-V curve tracer?

Sweep an electronic load across a solar panel and plot its I-V and power curves. You need ESP32 DevKit V1, INA219 Current Monitor, MOSFET IRLZ44N, LM358 Op-Amp, Solar panel 6 V 1 W, Resistor 10 Ω and Resistor 1 kΩ. It takes 7 steps and about 180 minutes.

Level
Intermediate
Time
About 180 min
Parts
7

Parts list

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

Wiring

FromToWhy
Panel plusINA219 VIN+Measures panel current
INA219 VIN-MOSFET drainLoad side of the shunt
MOSFET source10 ohm resistor to GND, and LM358 pin 2The resistor sets the current
LM358 pin 3ESP32 GPIO25 (DAC)Target voltage across the resistor
LM358 pin 11 k resistor, then MOSFET gateOp-amp drives the gate
LM358 pin 8 and pin 4ESP32 VIN (5 V) and GNDOp-amp power
Panel minus, ESP32 GND, INA219 GNDJoined togetherCommon ground
INA219 VCC, SDA, SCLESP32 3V3, GPIO21, GPIO22Sensor power and I2C

Code

A solar panel is not a battery: its current stays almost constant as you load it, then falls off a cliff near its open voltage. The best power comes at the knee of that curve, and that is the maximum power point a good charger tries to track. This build loads the panel in small steps with a MOSFET that the op-amp controls like a precise adjustable resistor, and the INA219 reads the voltage and current at each step. Sweep once with the panel in bright sun, once in shade and once at an angle, and the curves show how much current drops with light while the voltage barely changes. Keep the panel's short-circuit current in mind: do not set a maximum current above what it can give. The MOSFET dissipates the panel's power as heat, so a 1 W panel is fine, but a bigger panel needs a heatsink and a bigger sense resistor. Use only a small panel of about 6 V; a larger one can exceed the INA219's 26 V input and the MOSFET's limits. Arduino IDE with the ESP32 boards package 2.0.x, board "ESP32 Dev Module".

Runs on a virtual ESP32 Dev Module 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).

// Solar panel I-V tracer: the op-amp holds the voltage across the 10 ohm resistor at the DAC value, so the load current is
// DAC volts divided by 10 ohms. The sketch steps it up and records panel voltage and current. Library: Adafruit INA219.
// Board: ESP32 Dev Module. Open the Serial Monitor at 115200, then copy the CSV lines into a spreadsheet.
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina;
const int DAC_PIN = 25;
const int MAX_CODE = 130;      // about 1.7 V across 10 ohms = 170 mA: keep it at or below your panel's short-circuit current
void setup() {
  Serial.begin(115200);
  Wire.begin(21, 22);
  ina.begin();
  dacWrite(DAC_PIN, 0);
  delay(1000);
  Serial.println("Press Enter in the Serial Monitor to start a sweep.");
}
void loop() {
  if (!Serial.available()) return;
  while (Serial.available()) Serial.read();
  Serial.println("volts,milliamps,milliwatts");
  float bestP = 0, bestV = 0, bestI = 0;
  for (int code = 0; code <= MAX_CODE; code++) {
    dacWrite(DAC_PIN, code);
    delay(150);                                          // let the panel settle
    float v = ina.getBusVoltage_V();
    float i = ina.getCurrent_mA();
    if (i < 0) i = 0;
    float p = v * i;
    Serial.print(v, 3); Serial.print(','); Serial.print(i, 1); Serial.print(','); Serial.println(p, 1);
    if (p > bestP) { bestP = p; bestV = v; bestI = i; }
  }
  dacWrite(DAC_PIN, 0);
  Serial.print("Maximum power point: "); Serial.print(bestV, 2); Serial.print(" V, ");
  Serial.print(bestI, 0); Serial.print(" mA, "); Serial.print(bestP, 0); Serial.println(" mW");
}

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 ESP32 Dev Module with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

Press Enter in the Serial Monitor to start a sweep.

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
DAC at zeroCurrent near zero, open-circuit voltage
DAC risingCurrent rises in steps
Near the endVoltage falls quickly
Shade the panelCurrent falls, voltage nearly the same

If it does not work

Current stays zero

Check the common ground and the op-amp power.

Oscillating readings

Keep the 1 k gate resistor and short leads.

Negative current

Swap the INA219 VIN+ and VIN- wires.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the solar panel I-V curve tracer?

ESP32 DevKit V1, INA219 Current Monitor, MOSFET IRLZ44N, LM358 Op-Amp, Solar panel 6 V 1 W, Resistor 10 Ω and Resistor 1 kΩ.

How long does the solar panel I-V curve tracer take to build?

About 180 minutes for a intermediate maker, in 7 steps.

How do I know the solar panel I-V curve tracer works?

DAC at zero: Current near zero, open-circuit voltage. DAC rising: Current rises in steps. Near the end: Voltage falls quickly.

Current stays zero: what should I check?

Check the common ground and the op-amp power.

Oscillating readings: what should I check?

Keep the 1 k gate resistor and short leads.

Negative current: what should I check?

Swap the INA219 VIN+ and VIN- wires.