Introduction: Low Cost Solar Lighting Controller

Picture of Low Cost Solar Lighting Controller

Solar Lighting Controller based on PIC12F675 micro controller to be used with a Solar Panel, Battery and a LED 12V Light, it has built with affordable materials and its ready to use, just plug your devices and its done, this controller will function by itself with no need to turn on or turn off the LED Light or press a button for starting to charge its battery due to its program to do it autonomously.

Step 1: Materials and Tools

Picture of Materials and Tools

Materials

  • 1-1K ¼ Watt Resistor
  • 4-2,2K ¼ Watt Resistor
  • 2-4,7K ¼ Watt Resistor
  • 5- 10K ¼ Watt Resistor
  • 1- 3,3K ¼ Watt Resistor
  • 1-50K Trimming Potentiometer
  • 3-100nF (0,1uF) Capacitors
  • 2-22nF 25V Capacitors
  • 2-MBR1660 Schottky Barrier Rectifier
  • 4- Green LED Diodes
  • 2-BC547 Transistors
  • 2-IFR5305 MOSFET
  • 1-PIC12F675 Microcontroller
  • 1-7805 Voltage Regulator
  • 1- 8 Pin Base
  • 1- Aluminum Heatsink
  • 5- Insulation Composite TO-220 with M3 Screw Insulation Cap TO-220
  • 3- Terminal Wire Connectors
  • 3-20mm PCB Fuse Holders
  • 3-20mm 5 Amp Fuses
  • 1- PCB Board (4.3” x 4.3”) or 2 830 Points Protoboard
  • 5”- of Solid Core Wire (Red) for PCB Board or 4mts of Solid Core Wire for Protoboard (Black and Red, 4mts p/color)
  • Couche Paper (1 or 2 sheets).

Tools:

  • 1- Electric Wire Cutter
  • 1- Electrical Pliers
  • 1- Soldering Iron
  • 1- Soldering Flux
  • 1- Soldering Tin
  • 1- Solder Sucker
  • 1- PCB Drill
  • 2- Screwdrivers (Plus and Plane)
  • 1- Iron
  • 1- Used Cloth
  • 1- Plastic Recipient (for PCB Board)
  • 1- Ferric chloride Acid for PCB
  • Stainless Steel Scouring Pad
  • Some Water

Software and Hardware:

  • PICkit 2
  • MikroC (Only if you want to modify some code)
  • Microcontroller Programmer

Step 2: Circuit Diagram

Picture of Circuit Diagram

The very first step you need to do it's look at the circuit diagram, this is the way you will connect your components to function properly. If you are using just a protoboard with some wires just peel some strings and connect. But if you are using a PCB Board go to the next step. I put some datasheets from the less common components to make it easy for you.

Step 3: PCB Board

Picture of PCB Board

If you´ve decided to make a PCB Board follow this step, to get this complete, we need to do 5 things:

  1. The first thing is print the circuit, don’t worry I attached a PDF file with it, you must print it in a Couche sheet.
  2. The second thing is iron the circuit into the PCB Board, just put the Couche paper into the copper side of the PCB Board and adjust to fit properly, when you see that circuit’s tracks are sticking to the PCB Board correctly just stop ironing it and put the PCB Board in some water to clean the PCB Board.
  3. After cleaning the PCB Board, put some Ferric Chloride Acid into a plastic recipient with some water, and immerse PCB Board, Ferric Chloride Acid must cover all the surface of the board.
  4. When you only see the circuit’s tracks on the PCB Board remove it from Ferric Chloride Acid, clean the board with some water and sand it with a stainless-steel scouring pad
  5. Finally, you just have to drill the component´s holes.

Step 4: Functions and Logic

Picture of Functions and Logic

Functions:

Our Solar Lighting controller will function according the next conditions:

DAY:

If our controller detects sun light it will verify the amount of charge of the battery, if the battery its complete its ok, but if the battery is on low or medium charge the controller will start charging the battery until it detects that its complete.

NIGHT:

If our controller doesn’t detect sun light it will turn on the LED light, but only if the battery it’s on medium or complete charge, the controller verifies the amount of charge at night to do this. If the battery is on low charge, the controller turns off the LED light for saving energy and charge the battery next day.

Logic:

To make our solar lighting controller we will use the PIC12F675 microcontroller and it’s analog to digital converter pins, we will use them for detecting the amount of charge of the battery and the state of the day (Day or Night), besides detecting a voltage reference value for stablishing the battery levels (Complete, Medium, and Low Battery), all reads will be using a voltage divisor with resistors or using the potentiometer (50k). In addition to that we will use 2 pins as out for turning on the lights and starting charge the battery.

Step 5: PIC12F675 Ports

Picture of PIC12F675 Ports

Before start programming we need to know how we will use the pins of our micro-controller, well , that pins are use in this way:

Pin 1: (Vdd) 5V Input.

Pin 2: (GP5) I/O Port configured as output used to start charging the battery.

Pin 3: (GP4) I/O Port configured as input used to read the voltage of the Solar Panel for detecting the state of the day (Day or Night) (AN3).

Pin 4: (GP3) MCLR Port.

Pin 5: (GP2) I/O Port configured as output used to turn on the LED light (AN2).

Pin 6: (GP1) I/O Port configured as input for detecting the amount of charge of the battery (AN1).

Pin 7: (GP0) I/O Port configured as input for detecting a voltage reference value to stablish low, medium and complete charge levels (AN0).

Pin 8: (VSS) Ground.

Note: For GP0 Port we need to adjust the potentiometer between 3-2.5V depending on the battery full charge voltage. This is for stablish the low battery level, if the battery its below that voltage, the controller will detect Low Battery level.

Step 6: Programming

I will divide the controller’s code in 4 parts, but if you want I attach the complete code here, each part of our code its explained here:

Part 1:

The first part of our code is used to define our variables and constants, we will define as constants 2 ports of our microcontroller (PIC12F675) one for the solar panel (GP5) and another one for LED light (GP2), after that we will use another 3 constants to specify the channels for ADC lectures (chPot, chBat and chStat). Then we will define 4 variables for ADC Lectures, one for detect the status of the day (Day/Night), 2 for battery level and one for the voltage reference level (for stablish Low Battery level) .

Constants

#define panel GPIO.F5

#define carga GPIO.F2

#define chPot 0

#define chBat 1

#define chStat 3

Variables

int lectStat =0;

int lectBat1=0;

int lectBat2=0;

int lectPot=0;

Part 2:

On the second part of our code we need to initialize the microcontroller’s ports and specify some settings:

Settings:

ANSEL=0X10;

ADCON0=0X81;

CMCON=0X07;

VRCON=0X00;

Initialize Ports:

TRISIO.F0=1;

TRISIO.F1=1;

TRISIO.F2=0;

TRISIO.F3=1;

TRISIO.F4=1;

TRISIO.F5=0;

GPIO=0;

Part 3:

On the third part of our code, on the main method, we need to stablish the behavior of the controller during the day, to do that we need to know the status of the day, we will do this by reading the voltage of the solar panel, according to some lectures that I did, a solar panel offers a voltage about 12V during the day and less than 4V on night. We will use the library ADC_Read() for reading voltage, this library use channels for specify the port we are using, that’s why we stablished constants with channels in previous steps. After Reading the voltage we will use an if condition to know the state of the day, if the voltage read is more than 1.8V the system will detect day (we use this voltage value because the controller has a voltage divisor, the panel offers less than 4V but the microcontroller receive less than 1.8V), and if the voltage read is less than 1.8V is night. After knowing the status of the day we will stablish the behavior of the controller during the day, the first thing we need to do is read two voltages, one for the battery and the other one for the potentiometer (Bouner 3299), we need to know this values to know the battery level and stablish the Low Battery Range, after reading this we ask with an if conditional if the voltage read on the battery is less than the Low Battery Range, the system will detect that the battery is on low charge, (that’s why we need to adjust the voltage of the potentiometer according the battery full charge voltage), if the microcontroller detects low battery it will start charging it, after this condition we need to use an else instruction to do another read within it and specify that if the voltage is less than 3.9V( I use this value because that’s the value my battery is offering at full charge) we need to charge the battery. Finally, our code will seem like this:

ADC Lecture for knowing the status of the day

lectStat= ADC_Read(chStat);

Day Condition

//Day

if(lectStat>368){ //368 = 1.8v

Battery and Potentiometer reads

lectBat1=ADC_Read(chBat);

lectPot=ADC_Read(chPot);

Low battery condition

if(lectBat1

//low battery

panel=1; //charge the battery

carga=0;//LED Light off

}else{

//read the battery level again

lectBat2=ADC_Read(chBat);

Charge the battery until its complete

if(lectBat2<797){// 982= 3.9v

//medium battery

panel=1;//charge the battery

carga=0;// turn off LED Light

}else{

panel=0; //full charge battery

carga=0; //turn off LED Light

}

}

}

Note: We are turning off the LED Light because we are specifying the behavior of the controller during the day.

Part 4:

The final part of our code is about specifying the controller’s behavior on night, basically it’s the same behavior, we only have to turn on the LED Light, and specify that if the battery its on low level charge we have to turn off the LED Light. Our code will seem like this:

Day status

//Night

if(lectStat<368){ //368 = 1.8v

Battery and Potentiometer voltage lectures

lectBat1=ADC_Read(chBat);

lectPot=ADC_Read(chPot);

Low battery mode

if(lectBat1

//low battery

panel=0;//turn off Battery charging

carga=0;// turn off LED Light

}else{

//Second battery lecture

lectBat2=ADC_Read(chBat);

if(lectBat2<797){// 797 = 3.9v

//medium battery

panel=0; // turn off Battery charging

carga=1;// turn on LED Light

}else{

carga=1;

panel=0;//full charge battery

}

}

}

}

Note: We are turning off the LED Light on Low battery to save energy and continue functioning until the next day to charge again the battery. We don’t have to turn on the charge of the battery at night because the voltage that a Solar panel offers its too low to charge it.

And that’s all for our code, we just have to program our PIC12F675 with a PIC Programmer and Load the HEX file into it.

Step 7: Solder PCB Board

Picture of Solder PCB Board

Finally you just have to solder the components on the PCB Board and it’s done!, our controller is ready to use, just put in some case for protection.

Comments

Eric T (author)2017-04-11

Thank you for the instructable.

Eric T (author)2017-04-11

When the battery is charged (day). How do you consume the voltage from the solar panal(s)? Or does it hurt (S)panals to produce Voltage without a load?

gowri (author)2017-04-04

I like the way you explained step by step.Thank you for sharing.

tytower (author)2017-04-04

Thats a good instructable . I wondered how you set up the pins as in and out and I see now . I would like to use an ATTiny85 as I have plenty of these . Have you done that at all? Could save me reinventing the board to suit.

Swansong (author)2017-04-04

That's really neat :)

CarlosCobos94 (author)Swansong2017-04-04

Thanks!, i'm glad to hear that

About This Instructable

3,526views

72favorites

License:

More by CarlosCobos94:Low Cost Solar Lighting Controller
Add instructable to: