How To Make MPPT Solar Charge Controller

A solar charge controller is a device, which is connected between the solar panel and battery. Solar charge controllers make sure to charge battery correctly, and protect the battery from being damage by over charged. There are two types of solar charge controllers, PWM (Pulse Width Modulation) and MPPT (Maximum Power Point Tracking). PWM solar charge controllers have a direct connection from solar panel to the battery, it uses fast switching to regulate the charging voltage. The problem with PWM charge controller is that they cannot draw maximum power from solar panels some of the power is wasted. On the other hand, MPPT charge controllers are basically DC to DC converters have ability to draw maximum power from the solar panel. So today we are going to build an MPPT solar charge controller using Arduino and a few components. This MPPT solar charge controller is designed to charge 12V batteries, the input voltage can be from 15V to 40V and maximum current can be 40A, we can use both12V solar panels or 24V panels with this charge controller, so let’s build it all required things are given below.

Step 1 :

connect all components according to the circuit diagram.

Step 2 :

now upload this code to the Arduino.


#include <EEPROM.h>

#include <LiquidCrystal.h>

LiquidCrystal lcd(2,3,4,5,6,7);

int dut,pwm,v,j;

bool st,m;

float vo,vi,current,cutoff;

void setup() {

   lcd.begin(16, 2);
   
   lcd.clear();
   
   lcd.print("BAT-VOLT       ");
   
   lcd.setCursor(0,1); 
   
   lcd.print("BAT-AMP ");

   TCCR1B = TCCR1B & B11111000 | B00000001; // Set PWM frequency for D9 & D10:

   Serial.begin(9600);
   
   pinMode(9,OUTPUT);
   
   pinMode(10,INPUT);
   
   pinMode(11,INPUT);
   
   pinMode(12,INPUT);
   
   v=EEPROM.read(0);
   if(v>144)v=144;
   
     cutoff=float(v)/10;  
}

void loop(){ 
  
  j++;
  
  Serial.println(v);
  
  if(!digitalRead(10)&!digitalRead(11)&!digitalRead(12))st=0;
  
  if(digitalRead(11)&st==0){
    
    st=1;
  
    lcd.clear();
  
    if(m==1){
      
      EEPROM.write(0, v);
      
      lcd.print("BAT-VOLT       ");
      
      lcd.setCursor(0,1); 
      
      lcd.print("BAT-AMP ");
      
      }
      
    m=!m;
    
    }
    
  if(m==1){
    
    if(digitalRead(10)&st==0){
      
      st=1;
      
      v=v+1;
      
      }
    if(cutoff>144)cutoff=144;
    
    if(digitalRead(12)&st==0){
      
      st=1;
      
      v=v-1;
      
      }
      
     if(v<130)v=130;
     
     cutoff=float(v)/10;
     
     lcd.setCursor(0,0);
     
     lcd.print("Cut-off       ");
     
     lcd.setCursor(10,0);
      
     lcd.print(cutoff);
     
     lcd.print("V ");
     
      }
      
   if(m==0){
    
      current=0;

      vo=analogRead(A0);
   
      for(int i = 0; i < 100; i++) {
      
          current = current + (.049 * analogRead(A3) -25);// for 20A mode
          
          vo+= analogRead(A0);
  
        delayMicroseconds(100);
      
      } 
      
      current = current/100;
      
      if(current<0)current=0;
      
      vo=((vo*0.06)/100);
      
      if(vo>14.4)pwm--;
      
      if(pwm<0)pwm=0;
      
      if(vo<13.4)pwm++;
      
      if(pwm>100)pwm=100;
      
      analogWrite(9,pwm);
      
      Serial.print("duty cycle ");
      
      Serial.print(pwm);
      
      Serial.print("output volt ");
      
      Serial.print(vo);
      
      Serial.print("v  ");
      
      Serial.print("current ");
      
      Serial.print(current);
      
      Serial.println("A");
      
      if(j>40){
      
          j=0;
         
          lcd.setCursor(10,0); 
          
          lcd.print(vo);
          
          lcd.print("V ");
          
          lcd.setCursor(10,1); 
          
          lcd.print(current);
          
          lcd.print("A ");}

      } 
      
  delay(50);
    
    }
Components:
Gerber files :
Icon

Arduino mppt chr 3 - CADCAM.ZIP 158.51 KB 956 downloads

...
Project files :
Icon

New_mppt.rar 798.04 KB 1319 downloads

...

7 thoughts on “How To Make MPPT Solar Charge Controller”

Leave a Comment