20Wp battery-stored solar energy

Exporting Excess Energy

A simple way to export excessed energy, for example, the solar panel is collecting a high current and the battery is getting full, is to export that energy to other devices. For a small system, this seems too much of work; however, being able to export the extra energy to other users is powerful and make this small system a model for a larger solar power.

Schematic to export excess energy to external load with a P-MOSFET and a N-transistor

We would like to use a P-channel MOSFET as the main switch to turn on and off from the high-side of the external load. The R1 pulls up the Gate of IRF9540N to the Source voltage that makes the switch opens. When excess power is detected, a digital pin on ESP32 connected to R2 resistor pulled high which closes the BC337 and connecting the Gate pin the ground which then turns on the IRF9540N (close the circuit). If energy is no longer being excess, the R2 is pulled low which opens the BC337. The Gate is pulled up by R1 which then open the switch.

We will depend on the INA3221 sensor to tell us what the voltage of battery, and in combination with a MOSFET, a transistor, and a digital pin on ESP32 to turn on the export port. The power export port is closed by default.

Here is the function to control the transistor which in turn, controls the MOSTFET:

/*__________   control MOSFET  ___________*/
void ctrl_mosfet(float v_bat){
//  bat_vol, P MOSFET is closed circuit if VGS is -, 
// BC337 is a N transitor, closed if VBE is +
    Serial.printf("MOSFET status %d\n", mosfet_on);
    if ((v_bat > (v_bat_ok - v_delta)) & !mosfet_on){ //if battery voltage is higher and mosfet is off
    Serial.println("TURN MOSFET ON");
    digitalWrite(MOSFET, HIGH); // pull high 
    mosfet_on = true;   

    if ((v_bat <= (v_bat_ok + v_delta)) & mosfet_on){
    digitalWrite(MOSFET, LOW);
    Serial.println("TURN MOSFET OFF");
    mosfet_on = false;

We defined a value of battery's voltage that marks for excessive energy called v_bat_ok. Also, a v_delta was defined to create a range of value rather one point value that makes the MOSFET turns on/off constantly. In this setup, the MOSFET is turned on if the voltage of the battery is higher than the defined value plus a small delta value. It only is turned off if the battery's voltage lower than the v_bat_ok plus v_delta.

Data will be added later here.