In renewable energy systems like solar power setups, extracting maximum power from the photovoltaic (PV) panel is crucial for efficiency. This is achieved using a Maximum Power Point Tracking (MPPT) controller, which dynamically adjusts the operating point of the PV panel to harvest the most power. In this article, we’ll explore a Step-by-Step Guide to Building an MPPT Controller with Arduino and a Synchronous Buck Converter.

Disclaimer:

Advertisements

Before we start Building an MPPT Controller with Arduino, the first step is to know the MPPT and synchronous buck converter.

Understanding MPPT and Synchronous Buck Converter:

MPPT stands for Maximum Power Point Tracking. It’s a technique used in solar power systems (and sometimes wind turbines) to maximize the amount of power extracted from the solar panels under varying conditions.

Here’s how it works:

  • Solar Panel Output Varies: A solar panel’s electrical output (both voltage and current) changes depending on factors like sunlight intensity, temperature, and shading.
  • Maximum Power Point: For every set of conditions, there’s a specific voltage and current combination at which the solar panel produces maximum power. This is called the Maximum Power Point (MPP).
  • MPPT’s Role: An MPPT system is an electronic circuit that constantly tracks the output of the solar panel and adjusts the load to ensure that it’s always operating at or near its MPP. This maximizes the power transfer from the panel to the battery or grid.

Think of it like this: Imagine you’re pedaling a bicycle. You can generate the most power with a certain pedaling speed (cadence). If you pedal too slowly or too quickly, you produce less power. An MPPT is like the gears on your bike, automatically adjusting the resistance to keep you pedaling at the optimal speed for maximum power output.

For solar panels, the MPPT is like this:

Building an MPPT Controller with Arduino

Imagine you have a solar panel with an open-circuit voltage of 22V and a short-circuit current of 10A. If you draw no current from the panel, the voltage remains at 22V, but since the current is zero, the power output is:

Power=Voltage×Current=22V×0A=0W

On the other hand, if you draw the maximum current (10A), the voltage drops to 0V, resulting in:

Power=Voltage×Current=0V×10A=0W

In both extreme cases, the power output is zero.

Now, if you operate the solar panel at 17V, you might get around 8A of current. The power in this case would be:

Power=Voltage×Current=17V×8A=136W

This demonstrates the concept of Maximum Power Point Tracking (MPPT). MPPT ensures that the solar panel operates at the voltage and current combination where it delivers maximum power, which in this example is 136W at 17V.

Use of MPPT:

MPPT is primarily used in solar charge controllers, which regulate the charging of batteries in solar power systems. Here’s why it’s important:

  • Increased Energy Harvest: By constantly tracking the MPP, MPPT systems can increase the energy harvested from solar panels by up to 30% compared to traditional controllers that don’t use MPPT.
  • Efficiency in Varying Conditions: MPPT is particularly beneficial in situations where sunlight conditions change frequently, such as on cloudy days or when there’s partial shading on the panels.
  • Matching Panel and Battery Voltages: MPPT allows for more flexibility in matching the voltage of the solar panels to the voltage of the battery bank, improving system efficiency.

In summary, MPPT is a crucial technology for maximizing the efficiency of solar power systems by ensuring that the solar panels are always operating at their point of maximum power output.

 Now, let’s make our own MPPT controller. But before that, I’ll request you to read my other article:
Make an MPPT Solar charge Controller with a Synchronous Buck Converter

What is a synchronous buck converter:

synchronous buck converter is a type of DC-to-DC converter that steps down a higher input voltage to a lower output voltage efficiently. It’s widely used in modern electronics to power devices like microcontrollers, processors, and other low-voltage components.

***If you want to learn other DC/DC converters, read this article here.

Let’s break it down in simple terms:

  1. What Does It Do?
    • It takes a higher voltage (like 12V or 24V) and converts it to a lower, more usable voltage (like 5V or 3.3V).
    • It does this with very little energy wasted, making it ideal for battery-powered and energy-efficient systems.
  2. Why Is It Called “Synchronous”?
    • A regular buck converter uses a diode to control current flow, but a synchronous buck converter replaces the diode with a second transistor (called a MOSFET). This improves efficiency because MOSFETs waste less energy as heat compared to diodes.
  3. How Does It Work?
    • The converter switches the transistors (MOSFETs) on and off rapidly.
    • An inductor and capacitor smooth out the output, turning the pulsed voltage into a steady lower voltage.

Let’s take a closer look at how a synchronous buck converter works in a circuit.

In this example, the main control switch (a MOSFET) is placed at the top. This switch connects the input voltage to the output through an inductor for a specific period of time. During this phase, the inductor stores energy and helps regulate the current flow to the load.

When the control switch is turned off, the inductor tries to maintain the current flow. At this point, a diode is typically used to provide a path for the inductor’s current. However, this diode introduces a forward voltage drop, which results in energy loss and reduces the overall efficiency of the converter.

To overcome this limitation, the diode is replaced with a Synchronous Rectifier (SR) MOSFET. The SR MOSFET acts like a switch and has a much lower voltage drop compared to a diode. This significantly reduces power loss and improves the efficiency of the buck converter.

Building an MPPT Controller with Arduino

Now, the diode loss is significantly reduced because MOSFETs create a very low-resistance switching path for the inductor’s hold-up current. This improvement directly increases the efficiency of the converter.

The key to making this work is ensuring that the Synchronous Rectifier (SR) MOSFET switches on when the Control Switch (CS) MOSFET is off. However, it’s critical to introduce a dead-time gap between the switching of these two MOSFETs. This prevents both switches from being on simultaneously, which could create a short circuit path for the input source.

And that’s it! This approach ensures high efficiency and safe operation of the synchronous buck converter.

Now, let’s design our own MPPT controller circuit diagram using this concept. 

Building an MPPT Controller with Arduino:

Here is the circuit diagram of our MPPT controller using Arduino and a synchronous buck converter

Building an MPPT Controller with Arduino

In this circuit, you can see that Q1 and Q4 are additional MOSFETs, but they are configured and switched in a slightly unconventional manner through their gate signaling. These MOSFETs effectively function as diodes while also significantly reducing switching losses. By using MOSFETs instead of traditional diodes, the design takes advantage of their low forward voltage drop.

These additional MOSFETs are synchronized with the Control Switch (main MOSFET) to ensure proper operation and minimize energy loss. This setup is an advanced technique we utilize in our products to enhance both performance and efficiency, making it ideal for modern applications where energy optimization is critical.

In a typical synchronous buck converter using a gate driver like the IR2104, selecting the right inductor is crucial for achieving maximum efficiency alongside proper circuit configuration.

A higher inductance value simplifies control by reducing the current ripple, but it comes at the cost of increased resistive losses in the inductor due to the longer wire length or thinner wire used in high-inductance coils. Conversely, a lower inductance value minimizes resistive losses, enhancing efficiency, but it increases current ripple, which can make control more challenging and may lead to excessive stress on the components.

Thus, striking the right balance during inductor selection is vital to ensure optimal performance and efficiency. Proper calculations based on output current, switching frequency, ripple requirements, and load conditions are necessary to make the best choice.


Inductor selection guide:

Inductor selection is a critical step in designing a synchronous buck converter because it directly impacts efficiency, ripple current, and transient response. Here’s how to calculate the inductor value:

Building an MPPT Controller with Arduino

Key Parameters:

Before selecting the inductor, the following parameters need to be known:
1. Input Voltage (Vin)
2. Output Voltage (Vout)
3. Output Current (Iout)
4. Switching Frequency (f)
5. Inductor Ripple Current (ΔIL), typically 20-40% of the output current.


Formula to Calculate Inductor Value:

Where:

  • D=Vout/Vin ​​ is the duty cycle of the converter.

Step-by-Step Calculation:

  1. Define Ripple Current (ΔIL​):
    Ripple current is chosen as a fraction of the maximum output current:ΔIL=k⋅Iout where k is the ripple current ratio (e.g., k=0.3  for 30%).
  2. Determine the Duty Cycle (D):D=Vout/Vin.
  3. Calculate Inductance (L): Using the formula: L=Vout⋅(1−D)ΔIL⋅Fs.

Example Calculation:

Consider the following example:
Vin = 12V, Vout = 5V, Iout = 2A, f = 100kHz, and ΔIL = 30% of Iout.


1. Calculate the duty cycle:
   D = Vout / Vin = 5 / 12 ≈ 0.4167

2. Calculate the ripple current:
   ΔIL = 0.3 × Iout = 0.3 × 2 = 0.6A

3. Calculate the inductance:
   L = (Vout × (1 - D)) / (ΔIL × f)
     = (5 × (1 - 0.4167)) / (0.6 × 100,000)
     = (5 × 0.5833) / 60,000
     ≈ 48.6 μH


Thus, a 47 μH or 50 μH inductor would be a good practical choice.


Additional Considerations:

1. Saturation Current: The inductor must have a saturation current rating higher than the peak current in the circuit, which can be calculated as:
   Ipeak = Iout + (ΔIL / 2)

2. Core Material: Choose a core material with low losses at the operating frequency.
3. Size and Thermal Considerations: Ensure the inductor can handle the thermal and size constraints of your design.

You can read: All-in-One Electronic tools and Calculators links. This will guide you to design your inductor properly. Check in!

Now, a little bit of experience and practice will make this perfect. Now, let’s see what I made for me here. 

PCB of MPPT controller using Arduino:

Here is what I build.

Building an MPPT Controller with Arduino

Now, we need to test our circuit. To begin, we first need to develop the project algorithm and then proceed to write the code. In my project, I am using the Perturb and Observe (P&O) method as the MPPT algorithm. This is one of the most commonly used algorithms for such designs.

Although there are other algorithms available, I prefer the P&O method because of its simplicity and effectiveness in tracking the maximum power point of solar panels.

In this project, I want to structure the algorithm as follows:

  1. Bulk Charging Mode: When solar power is available, the system will begin charging the battery in Bulk mode. During this phase, the system will deliver the maximum current to the battery until the voltage reaches the predefined bulk maximum limit.
  2. Float Charging Mode: Once the bulk voltage limit is reached, the system will switch to Float mode. Here, the charging current will gradually decrease, maintaining the battery voltage at a safe level until it reaches the lowest current threshold.
  3. Rest Mode: After Float mode, the battery will enter a rest phase, where no charging occurs. This allows the battery to stabilize.
  4. Restart Charging: If the battery voltage drops below the defined rest voltage limit during the rest phase, the system will restart the charging process, beginning again with Bulk mode.

This approach ensures safe and efficient charging of the battery while optimizing its lifespan.

Note: The MPPT algorithm will be used only in bulk mode where the maximum power is necessary. But be noted that, once the battery reaches the bulk voltage limit, it should not exceed that voltage.

I have an article on lead acid battery charging. You can read

  1. Get a long life of your Lead-Acid battery by selecting the right charging method
  2. A smart Battery charger circuit design guide

Arduino code for our MPPT controller:

#include <Adafruit_SSD1306.h>
#include "Wire.h"

#define SCREEN_WIDTH 128     // OLED display width, in pixels
#define SCREEN_HEIGHT 32     // OLED display height, in pixels
#define OLED_RESET -1        // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C  ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// Analog input pins
#define SOLAR_VOLTAGE_PIN A2
#define SOLAR_CURRENT_PIN A3
#define BATTERY_VOLTAGE_PIN A0
#define BATTERY_CURRENT_PIN A1

// PWM pin
#define PWM_PIN 3

// Global variables
float solarVoltage = 0.0;
float batteryVoltage = 0.0;
float solarCurrent = 0.0;
float batteryCurrent = 0.0;

// Constants
const int PWM_FREQUENCY = 20000;  // 20 kHz

const int pwmMin = 1;         // Minimum duty cycle
const int pwmMax = 100;       // Maximum duty cycle
const float stepSize = 0.02;  // Step size for perturbation

// Global variables
float oldPower = 0;    // Previous power reading
float newPower = 0;    // Current power reading
int pwmDuty = pwmMin;  // Initial PWM duty cycle
int lockoutCnt = 0;
int batteryPercentage = 0;

//control variables
const int BULK = 0, FLOAT = 1, NONE = 2, FULL = 3;
int chargeStage = BULK;
const float minimumBatteryVoltage = 8.0;
const float voltageDifferenceThreshold = 1.0;
const float bulkChargeVoltageThreshold = 14.2;

//Float charging settings
const float LowestBatChargingCurrent = 0.3;  //Amp
const float BatUpperLimit = 13.8;            //Volt
const float BatLowerLimit = 13.6;            //volt

//Full charging settings
unsigned long lastCurrentStableTime = 0;
const unsigned long waitTime = 20 * 60 * 1000;


void setup() {
  // Initialize Serial
  Serial.begin(115200);
  IntDisplay();
  InitPWM20KHz();
  DispintMsg();
}

void loop() {


  solarVoltage = ReadSolarVoltage();
  batteryVoltage = ReadBatteryVoltage();
  solarCurrent = ReadSolarCurrent();
  batteryCurrent = ReadBatteryCurrent();

  SetChargingModes();


  if (chargeStage == BULK) {
    perturbAndObserve();
  } else if (chargeStage == FLOAT) {
    FloatCharge();
  } else if (chargeStage == FULL) {
    MaintainBattery();
  }


  dispPages();
  delay(500);  // Update every second
}

Code explanation:

#include <Adafruit_SSD1306.h> and #include "Wire.h"
These libraries are included to control the OLED display using the I2C protocol.

Then,

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

This initializes the OLED display with a resolution of 128×32 pixels and the I2C address 0x3C.

After that, there are some other variables for different purposes. Comments are already there.

In the main loop(),

void loop() {
  solarVoltage = ReadSolarVoltage();
  batteryVoltage = ReadBatteryVoltage();
  solarCurrent = ReadSolarCurrent();
  batteryCurrent = ReadBatteryCurrent();

  SetChargingModes();

  if (chargeStage == BULK) {
    perturbAndObserve();
  } else if (chargeStage == FLOAT) {
    FloatCharge();
  } else if (chargeStage == FULL) {
    MaintainBattery();
  }

  dispPages();
  delay(500);
}

Reading Sensor Data:

ReadSolarVoltage(), ReadBatteryVoltage(), ReadSolarCurrent(), and ReadBatteryCurrent() are functions (not shown here) that read analog data from the respective sensors to determine the solar panel’s and battery’s voltage and current.

Charging Mode Selection:

SetChargingModes() determines the current charging stage based on voltage, current, and thresholds.

Bulk Charging:

In the Bulk mode, the MPPT algorithm perturbAndObserve() is applied to extract the maximum power from the solar panel.

Float Charging:

If the battery voltage reaches the Bulk threshold, the system switches to Float mode using FloatCharge(), reducing current and maintaining a safe battery voltage.

Full Charging:

Once the battery reaches the float limits, the system enters the Full stage, where MaintainBattery() is used to ensure the battery remains charged and stable.

Display Update:

dispPages() updates the OLED display with system parameters (voltage, current, charge mode, etc.).

The loop has a delay of 500ms, meaning the display and calculations update every half a second.

Charging Modes in Detail:

  • Bulk Mode:
    The MPPT algorithm perturbs the PWM duty cycle to track the maximum power point of the solar panel.
  • Float Mode:
    The charging current is reduced, and the battery voltage is maintained between 13.6V to 13.8V.
  • Full Mode:
    After float charging, the battery is monitored. If the voltage drops below a specific threshold, the system restarts the charging process.

Now, the other codes are on different pages.

Building an MPPT Controller with Arduino

Let’s test the project.

Testing of our MPPT controller using Arduino:

Building an MPPT Controller with Arduino
Building an MPPT Controller with Arduino

Overall, the controller is working fine. The project is designed to make a bigger version of this. If you are interested, let me know.


Conclusion:

In this article, I have explained how to build an MPPT controller using Arduino, step by step, with detailed information. I hope this project will be highly beneficial for you. As a professional with extensive experience in similar projects, I’m confident in delivering high-quality solutions.

If you’re interested or have any questions, feel free to contact me!

For Professional Designs or Help:

Loading

Read more:

See you again!


MKDas

Mithun K. Das. B.Sc. in Electrical and Electronic Engineering (EEE) from KUET. Senior Embedded Systems Designer at a leading international company. Welcome to my personal blog! I share articles on various electronics topics, breaking them down into simple and easy-to-understand explanations, especially for beginners. My goal is to make learning electronics accessible and enjoyable for everyone. If you have any questions or need further assistance, feel free to reach out through the Contact Us page. Thank you for visiting, and happy learning!

4 Comments

CHIMEZIE · 01/02/2025 at 1:23 am

thank you very much for this project, please i will love to build this MPPT unit but i have some questions
1. the code dose not mention the allowed max charging current, so how dose the system chooses the correct current during bulk charge.
2. to increase the solar input voltage to 80 volts what do i need to change in the circuit apart from R8 and R9 voltage divider, also what has to change in the code to achieve this new input voltage level,, thanks..

    MKDas · 02/02/2025 at 11:29 am

    Thank you for your comment. Designing for higher voltage and current ranges requires careful attention to additional protective measures and voltage conversion stages.

    Current Range: There’s no specific limit on the maximum current in the code. The key is selecting a solar panel with the appropriate power (wattage) rating. The MPPT algorithm will always attempt to extract the maximum possible power from the panel.

    High-Voltage Input (e.g., 80V):

    Inductor (Coil) Design: Ensure the coil is optimized for higher voltages and currents.
    MOSFET Selection: Choose MOSFETs with adequate voltage and current ratings, low Rds(on), and high efficiency.
    Thermal Management: Use proper heat sinks and, if necessary, additional cooling fans.
    Temperature Monitoring: Include temperature sensors to monitor and protect against overheating.
    Power Supply and Voltage Sensing: Modify the power supply circuit and sensing stages to handle the higher voltage safely.
    Firmware Adjustments: Update code variables to accommodate higher operating ranges.
    If you need professional assistance, feel free to contact me on WhatsApp.

Enrique · 02/02/2025 at 9:42 pm

Excelente trabajo ,soy aficionado a la electrónica todo lo que tiene que ver con fuentes me interesa mucho y estas publicaciones me ayudan mucho para entender de forma practica el funcionamiento. muchas gracias, sigo todas sus publicaciones

    MKDas · 04/02/2025 at 11:15 am

    Thank you! 👍👍👍

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *