DIY Simple Cheap Automatic Solar backup power system for 12V System

Simple version using relay board

Solar power is a renewable energy from the sun. But there are times that is raining for several days and during those days, our solar power might not be sufficient for our needs. On this project we will create an automatic solar backup power system to automatically connect to the AC grid when the battery level gets very low.

On this project we will be using an arduino to automatically switch on a relay to turn on the backup power supply when the battery levels gets low.

About Solar backup power system

This project uses arduino nano to automatically turn on the power supply connected to the battery when the battery level reached critical low. We also have added a fan control to switch on the fan only when the power supply gets hot. Learn more about measuring voltage with arduino here:

Schematic

Schematic diagram of solar backup power system
Schematic diagram of solar backup power system

Here is a simple schematic diagram using a relay board module instead for easier assembly.

Simple version using relay board

The thermistor is used to sense temperature and must be placed near the power supply. The fan will automatically turn on when the temperature increases. The temperature sensitivity can be set on the arduino code.

But if you do not want to use an arduino, here’s a simpler approach. you just need to connect the SMPS(Switch mode Power Supply) directly to the battery.

The diode is for reverse current protection, it is optional because most cheap SMPS have very minimal circuit on the secondary and will only consume few milliamps if you power them.

Arduino Code

//tataylino.com
// *******   CONFIG   ******
#define FAN_TEMP_ON 650
#define BAT_LEVEL1 12
#define BAT_LEVEL2 12.5    // 30%
#define BAT_LEVEL3 13  // 40%
#define BAT_LEVEL4 13.5 // 
#define BAT_LEVEL5 14  // 100% (13.6V - 14.4V)
#define RELAY_ON 12.2 // batt voltage relay on

// variables
double batt_raw;
double battV;
int temp_raw;
bool led1 = false;
bool led2 = false;
bool led3 = false;
bool led4 = false;
bool led5 = false;
bool fan = false;
bool relay = false;

// Digital pins
int led1_pin = 7;
int led2_pin = 6;
int led3_pin = 5;
int led4_pin = 4;
int led5_pin = 3;
int relay_pin = 2;
int fan_pin = 8;

//Analog pin
int batt_pin = A1;
int temp_pin = A2;

void setup() {
  // put your setup code here, to run once:
  pinMode(led1_pin, OUTPUT);
  pinMode(led2_pin, OUTPUT);
  pinMode(led3_pin, OUTPUT);
  pinMode(led4_pin, OUTPUT);
  pinMode(led5_pin, OUTPUT);
  pinMode(relay_pin, OUTPUT);
  pinMode(fan_pin, OUTPUT);
  //digitalWrite(led1_pin, HIGH);
  //delay(1000);
}

void read_analogs(){
  batt_raw = analogRead(batt_pin);
  temp_raw = analogRead(temp_pin);
  // convert to voltage
  battV = double((batt_raw*5*3)/1023);
}

void batt_warning(){
  // warning for super low battery
  digitalWrite(led1_pin, HIGH);
  delay(200);
  digitalWrite(led1_pin, LOW);
  delay(200);
}

void loop() {
  read_analogs();
  if(led1){
    if(battV < BAT_LEVEL1-0.35)
    {
      led1 = false;
      digitalWrite(led1_pin, LOW);
    }
  } else {
    batt_warning();
    if(battV > BAT_LEVEL1)
    {
      led1 = true;
      digitalWrite(led1_pin, HIGH);
    }
  }
  
  if(led2){
    if(battV < BAT_LEVEL2-0.35)
    {
      led2 = false;
      digitalWrite(led2_pin, LOW);
    }
  } else {
    if(battV > BAT_LEVEL2)
    {
      led2 = true;
      digitalWrite(led2_pin, HIGH);
    }
  }
  
  if(led3){
    if(battV < BAT_LEVEL3-0.35)
    {
      led3 = false;
      digitalWrite(led3_pin, LOW);
    }
  } else {
    if(battV > BAT_LEVEL3)
    {
      led3 = true;
      digitalWrite(led3_pin, HIGH);
    }
  }

  if(led4){
    if(battV < BAT_LEVEL4-0.35)
    {
      led4 = false;
      digitalWrite(led4_pin, LOW);
    }
  } else {
    if(battV > BAT_LEVEL4)
    {
      led4 = true;
      digitalWrite(led4_pin, HIGH);
    }
  }

  if(led5){
    if(battV < BAT_LEVEL5-0.35)
    {
      led5 = false;
      digitalWrite(led5_pin, LOW);
    }
  } else {
    if(battV > BAT_LEVEL5)
    {
      led5 = true;
      digitalWrite(led5_pin, HIGH);
    }
  }

  if(relay){
    if(battV > RELAY_ON + 0.3)
    {
      relay = false;
      digitalWrite(relay_pin, LOW);
    }
  } else {
    if(battV < RELAY_ON)
    {
      relay = true;
      digitalWrite(relay_pin, HIGH);
    }
  }
  
  if(fan){
    if(temp_raw < FAN_TEMP_ON + 50)
    {
      digitalWrite(fan_pin, LOW);
      fan = false;
    }
  } else {
    if(temp_raw > FAN_TEMP_ON)
    {
      digitalWrite(fan_pin, HIGH);
      fan = true;
    }
  }

  delay(10);
}

References

https://www.arduino.cc/

Measuring Voltage with Arduino