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

1. Project Introduction

This project guides you through building a solar energy monitoring and control model using an ESP32, within an educational engineering scope. The system focuses on measuring voltage, current, and power from a solar panel, tracking the storage battery's voltage, and controlling a small DC load over MQTT.

This model suits learning IoT, renewable energy, DC electrical measurement, load control, and building a remote monitoring dashboard. It does not cover connecting to mains AC power, inverters, grid-tied systems, or high-voltage solar panel strings.

2. Technical Goals

GoalDescription
Measuring input energyUse an INA219 to measure bus voltage, current, and power within the module's allowed range.
Monitoring the storage batteryUse a voltage divider to bring the battery voltage down to a level safe for the ESP32's ADC pin.
Controlling the DC loadUse a relay or MOSFET module to switch a small DC load on/off, never powering the load directly from a GPIO.
Remote monitoringThe ESP32 sends telemetry to MQTT on a regular interval.
Basic protectionAutomatically turns off the load when battery voltage is low, and only turns it back on once the battery has recovered.

3. Safety Scope

This project only applies to low-voltage DC systems — a 6V, 9V, or 12V panel is recommended, along with a storage battery with protection circuitry or a matching charger, a small load current, and correctly sized wiring.

⚠️ Do not connect to 220V AC mains power. Do not connect an inverter. Do not connect a grid-tied solar system. Do not work with a high-voltage PV string. If the DC voltage exceeds 50V or the system has significant power, have a qualified electrician check it.

4. System Architecture

Solar Panel
  -> INA219 measures voltage, current, power
  -> Solar Charge Controller
  -> DC Storage Battery
  -> 5V Buck Converter
  -> ESP32

DC Storage Battery
  -> Relay or MOSFET module
  -> Small DC Load

ESP32
  -> MQTT Broker
  -> Monitoring & Control Dashboard

5. System Data

Data FieldMeaning
pv_voltageThe voltage measured at the solar panel line or the monitored source line.
pv_current_maThe current measured through the INA219, in mA.
pv_power_mwInstantaneous power, in mW.
battery_voltageBattery voltage, computed from the voltage divider.
loadThe DC load's status.
modeAUTO or MANUAL mode.

6. Pre-Power-On Checklist

Before powering the ESP32, use a multimeter to confirm the battery's polarity, the buck converter's output voltage, the voltage at the ADC pin after the voltage divider, and the expected load current.

✅ Only power on once the buck converter's output is stable, the ADC pin doesn't exceed 3.3V, and the DC load is within the relay's or MOSFET module's rated limits.

Detailed guide

List of extended articles for this project.