GithubHelp home page GithubHelp logo

angelocasi / fugu-arduino-mppt-firmware Goto Github PK

View Code? Open in Web Editor NEW
507.0 53.0 128.0 80 KB

An open source Arduino ESP32 MPPT Charger firmware equipped with charging algorithms, WiFi, LCD menus & more!

License: Creative Commons Zero v1.0 Universal

C++ 100.00%

fugu-arduino-mppt-firmware's Introduction

FUGU-ARDUINO-MPPT-FIRMWARE

An open source Arduino ESP32 MPPT Solar Charge Controller firmware equipped with charging algorithms, WiFi, LCD menus & more! Stay tuned for the design release and video tutorial.

fugu-arduino-mppt-firmware's People

Contributors

angelocasi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fugu-arduino-mppt-firmware's Issues

What is the purpose of "inputSource"

In the source code there is a parameter “inputSource”, which is assigned values in Read_Sensors.ino.
But I didn't find where it is used.
What is it for?

using structs

this isnt an issue but more of a design suggestion.

in the file 5_System_Processes you use EEPROM.write to save/load settings. i suggest you create a struct which holds your settings and then write the struct to eeprom. this would save you from needing to save twice for decimal

writing struct to eeprom

Battery voltage discovery and excessive overcharge voltage /Sate of charge reading

The problem with most MPPT chargers is that when they read the battery voltage they don't turn off the background charging current. This results in an elevated voltage reading on the line and messes the calculations around.
Somehow, you must first turn the charge off, then read the battery voltage ,then turn the charge back on.

Secondly with Lithium , the charge voltage must never be greater than the number of cells in the battery times 3.65 volts (4.2 volts for Li Ion). Otherwise this results in damage to the cells if the plate voltage gets too much "push force" (EMF). 16 cells for instance ,the top push must not go over 16 x 3.65v =58.4 volts .
If it does it has been shown by scientific experiment that 10 % over causes lithium dendrites and 20% over even causes the copper plate holding the lithium to start building copper dendrites too , both of which pierce the separator and short the cell.

There must be a check to ensue the current into the battery can never exceed a decided set figure (ie a 100 Ah cell usually is set no higher than .5 C or 50 Ah in this case)

Thirdly the SOC of a Lithium battery ,especially LiFePo4 ,LFP , cannot be done by simple division . The charging graph at say 3.3 volts is almost a straight line . Only the coulomb counting method will have any chance of being close.. I don't have a charge graph handy but will replace the discharge graph below when I find it.

CalbDischargeCurve200Ahcell

solar charge buck boost converter

@AngeloCasi just wonder if i can build a buck boost converter solar charge controller based on your project. what modification should i make on the code since buck boost converter need to control 2 mosfet. anyway i planned to use two switch buck boost converter topology.

P&O Algorithm

Hi
I have a problem with mppt algorithm about your code, as follow:

if(powerInput>powerInputPrev && voltageInput>voltageInputPrev)     {PWM--;}  //  ↑P ↑V ; →MPP  //D--
else if(powerInput>powerInputPrev && voltageInput<voltageInputPrev){PWM++;}  //  ↑P ↓V ; MPP←  //D++
else if(powerInput<powerInputPrev && voltageInput>voltageInputPrev){PWM++;}  //  ↓P ↑V ; MPP→  //D++
else if(powerInput<powerInputPrev && voltageInput<voltageInputPrev){PWM--;}  //  ↓P ↓V ; ←MPP  //D--
else if(voltageOutput<voltageBatteryMax)                           {PWM++;}  //  MP MV ; MPP Reached - 

About P&O Algorithm, if(powerInput>powerInputPrev && voltageInput>voltageInputPrev) , should increase PWM.
However,your code is the opposite of it, Can you explain?
Thank you!

Permission to copy the schematics and pcb design in KiCAD and publish it.

Hello Angelo,

Thank you very much for sharing this awesome project with the world. I learned a whole lot about synchronous buck converters and mppt, all thanks to your instructable.

I'm wondering if you would find it ok if I would copy your design in KiCAD and put it on Github (with full credits to you of course). I noticed there is no free version of the Proteus PCB Design software. And I would like to mod your design a bit for higher output current (50-60A).

Planning to build a solar boat with 2S5P solar panel configuration which would give a Voc of 100V and a Imp of 50A. The output would be a 48V lead-acid battery bank and a 3 kW electric motor. So while cruising, I'd need around 40A of output current for the motor plus some charging current if the battery is not full.

I intend to copy your schematics and pcb in KiCAD and, if it's ok with you, I'll share both the (copied) original and a version with my modifications on github.

Thanks again for sharing this project!

insn does not satisfy its constraints:

Hi, have a compile error "insn does not satisfy its constraints:" in LCD Menu.ino using latest 3.0.1 board manager.
Reverting back to 2.0.17 it compiles ok.
Is there a fix for the latest board manager?

IUV frequently occured / Algo behavior at the end of charge

Hello
I will provide my setup

  • 12V lead acid battery
  • 80W panel (16Voc 5A Isc)
  • 13.5V charging voltage
  • 3A charging current

I am facing two problems:

  1. When it's charging the algorithm try to lower the input voltage and increase the output current and it reach the 14.5V (charging voltage+dropoutvoltage) and the IUV occured resetting the charge current to 0 and everything restart so the efficiency of the algorithm is not optimal. did anyone encounter such a problem because i think it happens only with smaller panels
  2. How is the behavior of the algorithm at the end of charge cycle. I cannot see any code to pass from phase to phase or lower the current at the CV phase so the controller keep flow high current even the max voltage of the battery is reached

Could anyone support us with this problem?
Thank you again for your cooperation

Feature request: Save harvested energy on power loss

Hi, how about saving the harvested energy to the EEPROM when the power is lost?
Normally the MPPT charger will stay powered by the battery, but if there is any event where the battery is disconnected (for example because a BMS disconnects it for any reason) the most important data is lost.
The question is: Is the software loop fast enough to detect when the battery is disconnected and writing the value to the EEPROM in that case? For example store this value when the battery voltage drops below the the value stored in the EEPROM as minimum battery voltage.
Another idea (not for automatic storage): Store the harvested energy using the settings menu, that would be usefull in case of a software update on the MPPT charger.

BlynkApi.h:39:6

Hello
I was never able to assemble the project. When compiling, it gives an error:
/home/serhii/Arduino/libraries/blynk-library-master/src/Blynk/BlynkApi.h:39:6: error: #error "Please specify your BLYNK_TEMPLATE_ID and BLYNK_TEMPLATE_NAME"
I entered the data obtained from Blynk, tried different options.
I will give a fragment of the code (ARDUINO_MPPT_FIRMWARE_V1.1.ino):
...
/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPL4EZ-M8ZNG"
#define BLYNK_TEMPLATE_NAME "Quickstart Device"
#define BLYNK_AUTH_TOKEN "AQt5HJvwlsb8iFpShv7c0FQ8k9pgK7lF"
...
char
auth[] = "AQt5HJvwlsb8iFpShv7c0FQ8k9pgK7lF",// USER PARAMETER - Input Blynk Authentication Token (From email after registration)
ssid[] = "My Wi-Fi Home", // USER PARAMETER - Enter Your WiFi SSID
pass[] = "9P5TJ0ENy9Jye6He"; // USER PARAMETER - Enter Your WiFi Password
...

What could be the problem?

ideas for alternate backflow circuit

I wonder about the complicated backflow control circuit - after read your notes at instructables I could understand your decision a bit.
Did you test a charge pump solution (PWM from microcontroller, totem-pole driver)?

Here are some ideas how the problem could be solved easier - did you test anything about this...

  • use PMOS channel mosfet, higher Rdson - not preferred because of higher power losses
  • use hotswap controller as gate driver - they are not as expensive as the isolated DCDC-converter, I think
  • change the backflow NMOS from high side switching to low side switching - why don't you switch the negative input, it would be so much easier. The problem that then arises with the input voltage measurement can be solved with a simple operational amplifier.

Code readability improvements

Hello!
I just wanted to note that - while I really notice and appreciate the effort you spent to make your code easy to understand by adding a comment to virtually every single line - it is common practice to focus on having your code easily readable, as opposed to having to explain your code in comments. Good code should not need comments to explain what it does.

With the formatting you chose you actually need to condense your code lines in order to have them properly explained in the same line.
As an example, please evaluate the readability of this line:

if (ERR>0||chargingPause==1){buck_Disable();}           //ERROR PRESENT  - Turn off MPPT buck when error is present or when chargingPause is used for a pause override

in opposition to:

if (ERR > 0 || chargingPause == 1) {
    buck_Disable();  
}

I think the line expanded to 3 lines with proper spaces absolutely does not need any comment to explain what's going on and is rather easy to understand in one go while overflying the code to learn how it works.

I find it is rather exhausting and difficult to visually decode condensed lines, especially if the same occurs line after line. If you look at other peoples code you will find the expanded writing style is significantly more common.

Feature request: Add two switchable load outputs

@AngeloCasi I suggest to add two switchable load outputs with power measurement:

  1. Always on except for overload or battery under-voltage (e.g. DC lighting system, home automation, fridge, etc.)
  2. MPPT/PWM-controlled load (e.g. heating water) to use spare sun-power when batteries are fully charged or PV power is greater than load + charging power.

Feature request: 5 kW version

@AngeloCasi This is a great MPPT controller! :)

It would be great to have a 5 kW version to power a complete household, e.g.
20x photovoltaic panel at 240 W Pmax, 5A Imp/Isc, 50 Vmp/60 Voc.

Maintenance

Blynk shut down their legacy servers in December, so the Blynk API remains defunct.

Is anyone actively maintaining this or is there a fork?

We are in an early stage of commercialization the hardware among the open source spirit, so let me know if you want to contribute.

Use USB-C socket to avoid the need for a lot of different cables

@AngeloCasi
Currently the following 20 USB-cable host/slave socket-combinations are in use:

USB-A USB-A 3.0 USB-B USB-B 3.0 USB-B mini USB-B micro USB-B micro 3.0 USB-C
USB-A x x x x x
USB-A 3.0 x x x x x x x
USB-C x x x x x x x x

Basically you need 20 different cables at hand for all possible device combinations.

I want to encourage anyone to strictly go for USB-C sockets to reduce cable clutter.

Commercialization

I am keen to on this project and ready to help sponsor it along in the open source spirit. Please contact me for next steps.

Charging algorithm is dangerous

Right now, the charging algorithm is very dangerous. It's ok to connect the output to a BMS, but not to plug directly on a battery (whatever the chemistry).

It should follow charging curves and also respect the limits. Typically, a charging curve for a lead acid battery depend on the charge state of the battery, it c/should start with a voltage set up then once some threshold is reached, it should monitor the current and limit the current but keep the voltage in a desired range, and then once the charging current is 0, it should float by increasing the voltage while monitoring the current is low (else, it should go back to the CC mode).

Right now, the algorithm for charging is more a "try to respect all constraint" charging, that is: limit charging current, limit voltage, limit power. It's doing this with only a single feedback: the PWM duty cycle. This can't work to implement correct charging algorithm here, IMHO, since PWM only deal with power, not independant voltage or current.

I think another MOSFET & inductor is required here in buck/boost mode to implement a proper charging here, the goal of this is to decouple the power input (from the MPPT output) into either voltage or current control.

error: insn does not satisfy its constraints: 555 | }

I am only getting error for this part of SETTING MENU ITEM CHARGING CURRENT code rest part of the code is fine...

`///// SETTINGS MENU ITEM: CHARGING CURRENT /////
else if(subMenuPage==4)
{
lcd.setCursor(0,0);lcd.print("CHARGING CURRENT");
if(setMenuPage==1){lcd.setCursor(0,1);lcd.print(" >");}
else{lcd.setCursor(0,1);lcd.print("= ");
}
lcd.setCursor(2,1);lcd.print(currentCharging,2);lcd.print("A");
lcd.print(" ");

  //SET MENU - FLOATTYPE
  if(setMenuPage==0){floatTemp = currentCharging;}
  else
  {
    if(digitalRead(buttonBack)==1){while(digitalRead(buttonBack)==1){}currentCharging = floatTemp;cancelledMessageLCD();setMenuPage=0;} 
    if(digitalRead(buttonSelect)==1){while(digitalRead(buttonSelect)==1){}saveSettings();setMenuPage=0;savedMessageLCD();}     
    currentMenuSetMillis = millis();
    if(digitalRead(buttonRight)==1)
    {                                                  //Right button press (increments setting values)
      while(digitalRead(buttonRight)==1)
      {
        if(millis()-currentMenuSetMillis>longPressTime)
        {                              //Long Press     
          currentCharging += 1.00;                                                    //Increment by 1
          currentCharging = constrain(currentCharging,0.0,cOutSystemMax);             //Limit settings values to a range
          lcd.setCursor(2,1);lcd.print(currentCharging,2);delay(longPressInterval);   //Display settings data                               
        }
        else
        {                                                                         //Short Press  
          currentCharging += 0.01;                                                    //Increment by 0.01
          currentCharging = constrain(currentCharging,0.0,cOutSystemMax);             //Limit settings values to a range
          lcd.setCursor(2,1);lcd.print(currentCharging,2);delay(shortPressInterval);  //Display settings data                            
        }  
        lcd.print("A   ");                                                            //Display unit
      } 
    }
    else if(digitalRead(buttonLeft)==1)
    {                                              //Left button press (decrements setting values)
      while(digitalRead(buttonLeft)==1)
      {
        if(millis()-currentMenuSetMillis>longPressTime)
        {                              //Long Press     
          currentCharging -= 1.00;                                                    //Increment by 1
          currentCharging = constrain(currentCharging,0.0,cOutSystemMax);             //Limit settings values to a range
          lcd.setCursor(2,1);lcd.print(currentCharging,2);delay(longPressInterval);   //Display settings data                               
        }
        else
        {                                                                         //Short Press  
          currentCharging -= 0.01;                                                    //Increment by 0.01
          currentCharging =  constrain(currentCharging,0.0,cOutSystemMax);            //Limit settings values to a range
          lcd.setCursor(2,1);lcd.print(currentCharging,2);delay(shortPressInterval);  //Display settings data                                      
        } 
        lcd.print("A   ");                                                            //Display unit
      } 
    }
  } 
}`

ERROR

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.