top of page

Arduino based 2 Axis Solar Tracking using LDR

Updated: Feb 13

Here is a solar tracker system that tracks the sun’s movement across the sky and tries to maintain the solar panel perpendicular to the sun’s rays, ensuring that the maximum amount of sunlight is incident on the panel throughout the day. The solar tracking system starts following the sun right from dawn, throughout the day till evening, and starts all over again from the dawn next day.


Circuit Diagram:



Components:

Arduino Uno - 1 no

Servo Motor SG 90- 2 nos

Pan/Tilt Bracket Kit (Multi Attachment) - 1 no

LDR medium size - 4 nos

4k7 Resistor - 4 nos

Battery 9 V- 1 no

Solar Panel - Optional


For Programmed ardunio Uno & Price:


Explanation:

Let us design a solar tracker using two servo motors, a light sensor consisting of four LDRs and Arduino UNO board. Four LDRs and Four 100KΩ resistors are connected in a voltage divider and the output is given to 4 Analog input pins of Arduino. The PWM inputs of two servos are given from digital pins 9 and 10 of Arduino.



LDRs are used as the main light sensors. Two servo motors are fixed to the structure that holds the solar panel, one for the horizontal position and one for vertical position. LDRs sense the amount of sunlight falling on them. Four LDRs are divided into top, bottom, left and right.


For east – west tracking, the analog values from two top LDRs and two bottom LDRs are compared and if the top set of LDRs receive more light, the vertical servo will move in that direction. If the bottom LDRs receive more light, the servo moves in that direction.


For angular deflection of the solar panel, the analog values from two left LDRs and two right LDRs are compared. If the left set of LDRs receive more light than the right set, the horizontal servo will move in that direction. If the right set of LDRs receive more light, the servo moves in that direction.


Program Code:

#include <Servo.h>

//defining Servos

Servo ServoMotorH;

int ServoHorizotal = 0;

int ServoHorizotalLimitHigh = 160;

int ServoHorizotalLimitLow = 20;

Servo ServoMotorV;

int ServoVertical = 0;

int ServoVerticalLimitHigh = 160;

int ServoVerticalLimitLow = 20;

//Assigning LDRs

int LDR1 = 0; //top left

int LDR2 = 1; //top right

int LDR4 = 3; // bottom left

int LDR3 = 2; // bottom right

void setup ()

{

ServoMotorH.attach(10);

ServoMotorH.write(0);

ServoMotorV.attach(9);

ServoMotorV.write(0);

delay(500);

}

void loop()

{

ServoHorizotal = ServoMotorH.read();

ServoVertical = ServoMotorV.read();

//capturing analog values of each LDR

int NorWes = analogRead(LDR1);

int NorEas = analogRead(LDR2);

int SouWes = analogRead(LDR4);

int SouEas = analogRead(LDR3);

// calculating average

int NORTH = (NorWes + NorEas) / 2; //average of top LDRs

int SOUTH = (SouWes + SouEas) / 2; //average of bottom LDRs

int WEST = (NorWes + SouWes) / 2; //average of left LDRs

int EAST = (NorEas + SouEas) / 2; //average of right LDRs

if (NORTH < SOUTH)

{

ServoMotorV.write(ServoVertical +1);

if (ServoVertical > ServoVerticalLimitHigh)

{

ServoVertical = ServoVerticalLimitHigh;

}

delay(15);

}

else if (SOUTH < NORTH)

{

ServoMotorV.write(ServoVertical -1);

if (ServoVertical < ServoVerticalLimitLow)

{

ServoVertical = ServoVerticalLimitLow;

}

delay(15);

}

else

{

ServoMotorV.write(ServoVertical);

}

if (WEST > EAST)

{

ServoMotorH.write(ServoHorizotal +1);

if (ServoHorizotal > ServoHorizotalLimitHigh)

{

ServoHorizotal = ServoHorizotalLimitHigh;

}

delay(15);

}

else if (EAST > WEST)

{

ServoMotorH.write(ServoHorizotal -1);

if (ServoHorizotal < ServoHorizotalLimitLow)

{

ServoHorizotal = ServoHorizotalLimitLow;

}

delay(15);

}

else

{

ServoMotorH.write(ServoHorizotal);

}

delay(50);

}


Demo:


Pay and get arduino code




842 views0 comments

Comments


bottom of page