Solar Energy Monitoring and Control System with ESP32
Intermediate11/6/2026- Author: IoTSpark Maker

Solar Energy Monitoring and Control System with ESP32

Build a low-voltage DC model using an ESP32 to measure solar voltage, current, and power, monitor a battery, and control a DC load over MQTT.

ESP32Solar EnergyMQTTINA219IoTDC PowerEnergy Monitoring
6 steps9 components
← Back to project
Detailed guide

Part 3: Wiring the ESP32, INA219, Battery, and DC Load

Guides you through wiring the INA219 over I2C, measuring panel current, measuring the battery via a voltage divider, powering the ESP32 through a 5V buck converter, and controlling the DC load.

Updated 31/08/2026

Part 3: Wiring the Hardware

This part guides you through wiring block by block, for easier testing. Never power up the entire system all at once. Wire each part, remeasure with a multimeter, and only then connect the ESP32.

Connecting the INA219 to the ESP32

INA219ESP32Function
VCC3V3Logic power for the INA219 module, if it supports 3.3V.
GNDGNDCommon ground.
SDAGPIO21I2C data.
SCLGPIO22I2C clock.

Wiring the Current-Sensing Path Through the INA219

Solar Panel +  -> INA219 VIN+
INA219 VIN-    -> Solar Charger PV+
Solar Panel -  -> Solar Charger PV-

This wiring routes current from the panel through the INA219's shunt before reaching the charge controller. If the current reads negative, recheck the VIN+/VIN- direction.

⚠️ Never exceed the INA219 module's rated bus voltage and current limit. The maximum current depends on the shunt resistor and module design, not just the IC.

The Battery-Voltage Divider Circuit

Battery +  -> R1 100kΩ -> GPIO34 -> R2 22kΩ -> GND

The midpoint between R1 and R2 connects to GPIO34. Before plugging it into the ESP32, measure the voltage at this midpoint with a multimeter. The reading must stay below 3.3V under any full-charge condition.

Wiring the Buck Converter to Power the ESP32

Buck ConverterConnectionCheck
IN+Battery + after the charge controller, or a suitable battery outputCorrect polarity.
IN-Battery -Power ground.
OUT+ESP32 5V/VIN or the USB portMeasure it reads about 5V before plugging in the ESP32.
OUT-ESP32 GNDCommon ground.

Wiring the Relay or MOSFET Load Controller

Control ModuleESP32 or Power SourceNote
INGPIO26Control signal.
VCCPer the module, usually 3.3V or 5VCheck the module's documentation.
GNDCommon GNDMust share ground with the ESP32 if driven directly.
LOAD inputBattery + through a fuseNever draw load current from the ESP32.
LOAD outputDC Load +The load must match the correct voltage and current.

✅ After wiring, check in order: battery polarity, the buck converter's 5V output, the GPIO34 voltage after the divider — only then flash the code and apply full power.