Photovoltaic (PV) cells exhibit a nonlinear voltage–current (V–I) characteristic, where the current remains nearly constant at low voltages and then drops sharply as the voltage approaches the open-circuit value (Voc). At zero voltage, the current is maximum, known
as the short-circuit current (Isc), while at zero current, the voltage reaches Voc. The power output of the PV cell, given by 𝑃 = 𝑉 × 𝐼, varies with the operating point and produces a power–voltage (P–V) curve that peaks at the Maximum Power Point (MPP). This point, defined by 𝑉𝑚𝑝𝑝and 𝐼𝑚𝑝𝑝, represents the condition where the panel delivers maximum power. Since the MPP shifts with changes in irradiance and temperature, MPPT techniques
are required to ensure optimal energy extraction.

The Perturb and Observe (P&O) method is used to track the maximum power point.

A typical lithium-ion cell has a nominal voltage of 3.6 V with a maximum voltage of 4.2 V and is generally discharged to a cutoff voltage of 2.5 V. 

The system uses two sensors to monitor both the input (solar panel) and output (battery) side power. This is implemented using two INA219 current sensor modules interfaced via I2C, which provide measurements of voltage and current. From these values, input and output power are computed as 𝑃 = 𝑉 × 𝐼. These measurements are sampled at regular intervals (50 ms).

The control algorithm operates in multiple modes for efficiency and safe battery charging. Initially, an Under Voltage Lockout (UVLO) condition checks whether the input voltage is sufficient for operation. If not, the converter is disabled. If enabled, the system operates in
MPPT, CC or CV mode. In MPPT mode, the Perturb and Observe method is used. The PWM duty cycle is adjusted based on changes in input power and voltage to track the maximum power point. An outer check is implemented, which checks whether the output stays within specified voltage and current levels. If the current exceeds the threshold, the system enters Constant Current (CC) mode, and if the battery voltage exceeds its threshold, it switches
to Constant Voltage (CV) mode. The working logic of the MPPT solar charge controller is run by the ESP32. The solar panel generates DC voltage which varies with sunlight. INA219 sensor continuously measures panel parameters like voltage and current. The  microcontroller reads this value though i2c channel. The MPPT algorithm calculates the instantaneous power and determines the optimal duty cycle. A PWM signal (19kHz and 12bits) is generated to drive the buck converter switch (MOSFET). The buck converter adjusts its output voltage to ensure efficient charging of the battery. Battery voltage is continuously monitored to prevent overcharging. The entire control loop operates continuously to ensure maximum efficiency
and safety.
Now, this project was to mainly test out the MPPT algorithm and the charging process. Major disadvantage was the size of the PV panel. Being so, small it couldn't power the ESP32.