- Nov 21, 2026
- 4 min read
The Voltage Divider Is Where Software People Get Humble
I wanted the ESP32 to report the solar panel’s voltage. Simple, I thought. The ESP32’s ADC tops out around 3.3 V. The panel is “12 V”, but open-circuit it can go much higher. So the first job was making sure the pin never sees more than it can take.
The divider, on paper first
panel+ ---- 100 kΩ ----+---- GPIO34 (ADC1)
|
10 kΩ
|
panel- ----------------+---- ESP32 GND
A 100 kΩ / 10 kΩ divider scales the input by 11. The numbers:
| Panel voltage | At the pin | Comment |
|---|---|---|
| 12 V nominal | ~1.09 V | comfortable |
| 18.5 V (measured in sun) | ~1.68 V | still mid-range |
| 30 V design ceiling | ~2.73 V | still under 3.3 V |
Power burnt in the divider at 30 V is about 8 mW in total. Quarter-watt resistors don’t notice. GPIO34 is on ADC1, which keeps working while Wi-Fi is on (ADC2 doesn’t on the classic ESP32), and the firmware averages several samples per reading.
A divider measures voltage, not current
This is the part the quick tutorials skip. Voltage tells you the panel is lit. It doesn’t tell you how much energy is going anywhere. For that you need current, and current means something in series with the power path.
That’s the INA226: a shunt resistor plus a chip that reads the tiny voltage across it, on I²C.
charger BAT+ -> INA226 IN+ -> shunt -> INA226 IN- -> BMS charge +
INA226 SDA/SCL -> GPIO21/22 VCC -> 3V3 A0/A1 open -> address 0x40
In the charging setup the CN3722 board does the MPPT and the charging, and the
ESP32 only observes. It is not the battery protection; the BMS is. The
firmware assumes a 0.1 Ω shunt, so current and power are only trustworthy once
the real shunt value and its current rating are confirmed. Until the INA226 is
fitted and found at 0x40, current and power are published as missing, not as
zero.
Two readings that looked fine
1. The floating input. Before the divider was even wired, the dashboard showed panel values between 1.5 and 4 V. A floating ADC pin picks up noise and reports it with total confidence. The chart looked like a real, slightly cloudy day.
2. The buck converter. On USB power the panel reading was accurate. Powered from the buck converter that drops the 3S battery to 5 V, it jumped between about 16.3 and 18.8 V while the panel sat at 18.5 V. A meter between the buck’s negative and the ESP32’s ground read about 0.08 V: the grounds weren’t quite the same ground, and switching noise was moving the ADC reference.
The tempting fix was a calibration factor in firmware. That would have hidden the problem, not fixed it. USB power proved the divider values were right, so the fix belongs in the wiring: a short, direct ground wire from buck negative to ESP32 GND, then check with a meter:
buck + to ESP32 GND ~5.0 V
panel - to ESP32 GND ~0 V
buck - to ESP32 GND ~0 V
GPIO34 to ESP32 GND ~1.65–1.70 V at an 18.5 V panel
Wiring rules I now write down first
- The buck’s 5 V goes to the ESP32’s 5V/VIN pin, never to 3V3.
- The 3V3 rail feeds only small sensors (INA226, DHT11). No panel, charger, battery or buck output near it.
- The INA226 goes in series with the positive line, never across it.
- A DHT11 module usually has its pull-up on board; a bare sensor needs one.
Takeaways
- Design for the worst case, not the label on the panel.
- A number on a dashboard isn’t proof a sensor works. Floating pins and noisy grounds both produce believable charts.
- Fix wiring with wiring. A calibration constant on top of a ground problem just moves the error.
Next in this series: Controlling a Pump Without Flooding the House
Part 3 of 8. Start with the series overview.