Why Raw ESP32 ADC Readings Drift
Case Study: 800W MPPT Solar Charge Controller
800W MPPT Solar Charge Controller
An 800W synchronous-buck MPPT solar charge controller for off-grid battery systems using an ESP32, Incremental Conductance tracking, and cal...1. Clean Up the Analog Input First
- Op-Amp Gain Stage: Use a rail-to-rail op-amp like the LM358 or INA180. Set the gain so full load current sits near 2.4 V. That keeps the signal inside the ESP32 ADC's clean middle range (150 mV to 2450 mV).
- RC Filter: Put a 1 kΩ resistor and 100 nF cap right before the GPIO pin. That gives a ~1.59 kHz cutoff and cuts MOSFET switching noise.
- Bypass Cap: Keep a 100 nF ceramic cap next to the pin so the ADC sample cap charges fast with no voltage dip.
2. Average 64 Samples in Firmware
Tip: Always pick ADC1 pins (GPIO32 to GPIO39) if your code uses Wi-Fi or BLE. ADC2 shares hardware with the Wi-Fi radio and can fail or return junk when packets send.
3. Fit a Third-Order Curve on the Bench
- Pull known loads (0 A, 2 A, 5 A, 10 A, 15 A, 20 A, 25 A, 30 A) with a DC load.
- Log the averaged raw ADC count x and the true current I from a good bench meter.
- Fit a third-order curve I = a*x^3 + b*x^2 + c*x + d in Python with numpy.polyfit(x, y, 3).
Results on the 800W Buck Board
Deep Dive: 800W MPPT Hardware & Thermal Review