Arduino Based Solar Tracker

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

🔆

Arduino Based Solar Tracker


Table of Contents
Introduction
A little bit of ታRiC 📚
How does a Solar Tracker work? ⚙
1. Detecting the position of the Sun:
2. Movement along the position of the Sun:
Components Required for making the Solar tracker 🔧
Main components
Optional components
Servo motor
Light Dependent Resistor (LDR)
Project Development Methodology 🛣
1. Proof of concept phase
components required for this stage
Circuit Diagram
Step by Step procedure
Code/Program
Alternative approach
2. Minimum viable product (MVP) development phase:
components required for this stage
Circuit Diagram
Step by Step procedure
Code/Program
The solar tracker in operation
3. Building a Prototype
Components required for this stage
Schematics and Connection of the Solar Tracker
Step by Step procedure
Code/Program
Video
Conclusion

Arduino Based Solar Tracker 1


.

Introduction
In this project , we will have fun building a solar tracker using Arduino and other components. But what is a
Solar tracker? One of the biggest crisis we are facing currently is climate change due to excessive use of fossil
fuels. One way of avoiding this problem is with the utilization of Renewable Energy. Renewable energy is a
type of energy that is harnessed from the nature without causing ill effects to the environment. Solar energy is
among the most prominent kinds of renewable energy. Solar radiation from the sun is collected by solar panels
and converted into electrical energy. The output electrical energy depends on the amount of sunlight falling on
the solar panel.
Traditionally, solar panels are fixed and the movement of sun over the horizon means that the solar panel does
not harness maximum energy most of the time. In order to maximize the power from the solar panel, the panel
should face the sun all time. In this project, we will make a Sun tracking
 system which will help the solar panels to generate maximum power. The most-common applications for solar
trackers are positioning solar panels also known as photovoltaic (PV) panels so that they remain
perpendicular to the Sun’s rays and positioning space telescopes
 so that they can determine the Sun’s direction. By keeping the panel perpendicular to the Sun, more sunlight
strikes the solar panel, less light is reflected, and more energy is absorbed. That energy can be converted into
power.

A little bit of ታRiC 📚


It all began with Edmond Becquerel, a young physicist working in France, who in
1839 observed and discovered the photovoltaic effect — a process that produces a
voltage or electric current when exposed to light or radiant energy. A few decades
later, French mathematician Augustin Mouchot was inspired by the physicist’s work.
He began registering patents for solar-powered engines in the 1860s. From France to
the U.S., inventors were inspired by the patents of the mathematician and filed for
patents on solar-powered devices as early as 1888.

Arduino Based Solar Tracker 2


Charles Fritts installed the first solar panels on New York City rooftop in 1884. Courtesy of John Perlin

This view of the starboard solar array wing panel of the International Space Station (ISS) was photographed in 2002 with a digital
still camera from inside the crew cabin of the Space Shuttle Endeavour. NASA

How does a Solar Tracker work? ⚙


You must be wondering how does it work? There can be multiple ways of adjusting the solar panel to face the
sun to harness maximum power. The basic principle we will follow throughout the project to track sunlight is
done by first detecting the position of the sun and secondly by moving the panel along with it. We will try to
design a single-axis solar tracking system. In this system, the whole solar panel moves from east to west in a
day to point in the direction of the sun. The use of a solar tracker circuit in the field of energy production will
increase its efficiency. This system can also be successfully implemented in other solar energy-based projects
like water heaters and steam turbines.

1. Detecting the position of the Sun:


We measure the intensity of light with LDRs ( Light dependent resistors: also know as a photocell or
photoresistor ) using Arduino and compare the intensity of light falling on both LDRs. The LDRs are placed on

Arduino Based Solar Tracker 3


the edge of the solar panel as shown in the figure below.

💡 Here we can brainstorm and come up with different positions of LDRs that best measures the
intensity of sunlight. It would also be very useful to be able to differentiate between intensity values
such as “ bright “ and “very bright”

Did you notice the bulb icon above ? you will find those icons through out the
guideline of this project and they are used to show areas of the design where you can
suggest alternative or different approaches you may think appropriate

2. Movement along the position of the Sun:


Based on the intensity of light on the LDR, we give the signal to the servo motor to cause the movement.
When the intensity of the light falling on the right LDR is more, the panel turns towards the right and if the
intensity is higher on the left then the panel slowly turns towards the left side.

In the morning the sun rises from east side and therefore it has more light intensity than the west side, so the
panel moves towards to east side. Throughout the day it will track the sun and by the evening, sun has moved
towards the west, hence it will have more intensity than the east direction so the panel will face the west
direction.

Arduino Based Solar Tracker 4


Components Required for making the Solar tracker 🔧

Main components
1 x Arduino Uno

1 x Servo motor

1 x Solar panel

2 x LDR

2 x 10k Resistor

Jumper wires

Optional components
Tact switch (button)

Breadboard

5 to 12V power supply

1 x MDF board

We will now take a look about some of the main components in detail

Servo motor

Arduino Based Solar Tracker 5


A servo motor
 is a type of motor that can rotate with great precision. Normally this type of motor consists of a control circuit
that provides feedback on the current position of the motor shaft, this feedback allows the servo motors to
rotate with great precision. If you want to rotate an object at some specific angles or distance, then you use a
servo motor. It is just made up of a simple motor which runs through a servo mechanism. If motor is powered
by a DC power supply then it is called DC servo motor, and if it is AC-powered motor then it is called AC servo
motor. If you wanna learn more about servo motor and understand the working principle behind it, make sure
to check out this article .
Servo motor is used to rotate the solar panel. We are using servo motor because we can control the position
of our solar panels precisely and it can cover the whole path of sun. We are using a servo motor that can be
operated with 5volt.

💡 Based on your reading and understanding of servo motors can you set up one on a bread board and
control its movement ? come up with ways to connect the servo motor to the Arduino to control its
movement and discuss it with the team

Light Dependent Resistor (LDR)


A light-dependent resistor is made from semiconductor material having light-sensitive properties and hence
are very sensitive to light. The resistance of LDR changes according to the light that falls on it and it is
inversely proportional to the intensity of light. That is resistance of the LDR will increase at high-intensity light
and vice versa.

Arduino Based Solar Tracker 6


Project Development Methodology 🛣
The project development phase is mainly divided into three main categories

1. Proof of concept phase: Where we get ourselves familiar with the working principle of the solar trackers
and get comfortable using different components used in the project. This stage helps has get a solid
foundation on the basics of Solar tracker and how they work.

2. Minimum viable product (MVP) development phase : This is the stage where we actually come up with
new ideas and concepts to integrate into our design. We will develop a product with enough features to
validate the product idea early in the product development cycle. This stage help the product team receive
feedback as quickly as possible to iterate and improve the product

3. Building a prototype : This is the stage where the product is built into a model to test the concept and
process. Several design concepts will be captured in this phase and this is where we will make the final
basic model or design for the solar trackers.

Now lets look at each of the phase in detail

1. Proof of concept phase

Arduino Based Solar Tracker 7


In this stage we will see the working principle of solar trackers in action as well us get a good grasp of how
each components interact with each other to direct the tracker towards the sun. As you can see from the
picture this is a very basic setup of our system in which we used cardboard to represent the solar trackers and
show how the combination of the Arduino, LDR and servo motor creates the movements in the solar tracker.
You might have noticed we are only using 1 servo motor this is because We will design a single-axis solar
tracking system. In this system, the whole solar panel moves from east to west in a day to point in the direction
of the sun.

components required for this stage


1. Arduino Uno Board

2. Servo Motor SG90

3. Resistors 10K – 2

4. LDR – 2 Nos

5. Breadboard

6. Connecting Wires

7. Lcd screen (optional)

Circuit Diagram
The circuit diagram for the Arduino based solar tracker is given below . Assemble the circuit as shown below

Arduino Based Solar Tracker 8


Step by Step procedure
1. Fix the cardboard at the top of the servo motor that will face towards the Sun and rotate:

2. we can then simulate the setup on tinkercad to see how it is wired on the bread board. after that we can
wire the jumper cables onto our breadboard based on the simulation we did

Arduino Based Solar Tracker 9


Code/Program
For designing this tracker we need to program Atmega 328 Arduino microcontroller. Below is the program that
will interface with the servo motor & LDR. You can copy this code and upload it to your Arduino board. But
before that make sure to simulate it on TinkerCad.

#include <Servo.h>

#define spin 9 // Enable Pin for motor 1


#define ldr1 A0 // LDR pin A0 for sensor 1
#define ldr2 A1 // LDR pin A1 for sensor 2
Servo myservo;
int pos;
void setup() {

//set the pin mode for the motor to be an output


myservo.attach(spin);
myservo.write(90);
Serial.begin(9600);

void loop() {

// read the value from the sensor

int volt1 = analogRead(A0);


int volt2 = analogRead(A1);

// Convert the analog value into voltage

//float volt1=sensorValue*(5.0/1023.0);
//float volt2=sensorValue1*(5.0/1023.0);
int error=abs(volt1 - volt2);

if (volt1 > volt2){


myservo.write(45);

}
if (volt2 > volt1){
myservo.write(135);

Arduino Based Solar Tracker 10


}

if (volt2 == volt1) {
myservo.write(90);
}

//print voltages

Serial.print("sensorValue: ");
Serial.println(volt1);
Serial.print(' ');
Serial.print("sensorValue1: ");
Serial.println(volt2);
Serial.print('\n');

delay (1000);

💡 Try to come up with a way to integrate lcd screen that shows the angle of rotation of the tracker on
the display. you can see the output of that in the figure below

Alternative approach

In this project, we are going to show you how to make an Arduino Based Solar Tracker
Using LDR & Servo Motor. The solar panel tracker is designed to follow the sun movement
so that maximum light intensity hits on the solar panel, thus increasing the power efficiency.
https://youtu.be/4eb5eHZ8xew

2. Minimum viable product (MVP) development phase:

Arduino Based Solar Tracker 11


This is the phase where we will actually develop a product which has minimum features necessary to show the
solar tracker. This solar tracker control system is designed to take light measurements from the east and west
(left and right) side of the solar panel and determine which way to move the panel to point it directly at the
source of the light. A servo is used to actuate the panel tracker; these are available in a broad range of sizes
and can be scaled according to your panel size. Although this tracker is single axis, the two sensors and servo
can simply be duplicated to provide dual axis control.

components required for this stage


1. Arduino Uno Board

2. Servo Motor SG90

3. Resistors 2 x 4.7k

4. LDR x 2

5. Breadboard

6. Connecting Wires

7. MDF for tracking stand

Circuit Diagram
The circuit diagram for the Arduino based solar tracker is given below . Assemble the circuit as shown below

Arduino Based Solar Tracker 12


Step by Step procedure
1. First you need to start by assembling the components onto your solar panel. The LDRs (light dependent
resistors) or PRs (photo-resistors) change resistance with changing light, therefore they need to be
connected in such a way that the changing resistance is converted into a changing voltage signal which
the Arduino understands. The servo is controlled through one of the Arduino’s PWM outputs.

2. The resistors R1 and R2 are each 4.7K, the PR1 and PR2 are the two LDRs and the servo can be any
servo. If you are using a servo larger than 9 grams then the Arduino will probably not be able to supply it
enough power to achieve its full torque capability, you will need to supply the servo directly with its own 5v
power source.

Arduino Based Solar Tracker 13


If you are making this a permanent installation, then it is best to solder the resistors right up near the LDRs on
the panel. This way you can run a single 4 core wire from the control box up to the sensors on the panel, the
four cores will be 5V, Gnd and then signal 1 and 2 from the LDRs. Once your LDRs and resistors have been
soldered together, you can mount them on your solar panel. Mount the LDRs on the east and west (left and
right) sides of the panel facing towards the sun. Make sure that they are not shaded in any way by the frame
and have an unobstructed view of the sun

3. A breadboard has been used in this project purely to distribute the Ardunio’s 5V power supply to both the
resistors and the servo.

The servo needs to be sized according to the size of your solar panel. The panel used in this example is small
and relatively light; a small servo was therefore used and is powered by the Arduino. For a larger servo
(anything above 9 grams), you will need to power the servo externally as the Arduino doesn’t have sufficient
capacity for it. Make sure that you connect the external power sources ground to the Arduinos GND as well
otherwise the PWM control signal to the servo will not work.

Code/Program
4. Now you can upload your sketch onto your Arduino

#include <Servo.h>

Servo tracker; // create servo object to control a servo


int eastLDRPin = 0; //Assign analogue pins
int westLDRPin = 1;
int eastLDR = 0; //Create variables for the east and west sensor values
int westLDR = 0;
int error = 0;
int calibration = 204; //Calibration offset to set error to zero when both sensors receive an equal amount of light
int trackerPos = 90; //Create a variable to store the servo position

void setup()
{
tracker.attach(11); // attaches the servo on pin 11 to the servo object
}

void loop()
{
eastLDR = calibration + analogRead(eastLDRPin); //Read the value of each of the east and west sensors
westLDR = analogRead(westLDRPin);
if(eastLDR<350 && westLDR<350) //Check if both sensors detect very little light, night time
{

Arduino Based Solar Tracker 14


while(trackerPos<=160) //Move the tracker all the way back to face east for sunrise
{
trackerPos++;
tracker.write(trackerPos);
delay(100);
}
}
error = eastLDR - westLDR; //Determine the difference between the two sensors.
if(error>15) //If the error is positive and greater than 15 then move the tracker in the east direction
{
if(trackerPos<=160) //Check that the tracker is not at the end of its limit in the east direction
{
trackerPos++;
tracker.write(trackerPos); //Move the tracker to the east
}
}
else if(error<-15) //If the error is negative and less than -15 then move the tracker in the west direction
{
if(trackerPos>20) //Check that the tracker is not at the end of its limit in the west direction
{
trackerPos--;
tracker.write(trackerPos); //Move the tracker to the west
}
}
delay(100);
}

💡 Here try to compare the difference between this code and the one we did earlier . What new things
did this code add ? and how do we modify our previous code to accommodate error ?

5. Calibrate the sensor error

Because of differences between the LDRs, resistors and the resistance of the wire used, there will be a
difference between the signal received from both sensors even when they are receiving the same amount of
light. This is taken into account by introducing a calibration offset into the calculation, this number will need to
be adjusted in your code according to your setup. Adjust this calibration factor where it is declared in the code,

Line 13: int calibration = 204.

The most accurate way to determine this factor is to shine a light equally between both sensors and then use
the Serial monitor on your computer to read the values output by the east and west sensor. The difference
between these two values will be the calibration offset. The LDRs are very sensitive so the tracker only moves
when the difference between them is greater than 15 in the code otherwise it would be continuously tracking
forwards and backwards and wasting power.

Arduino Based Solar Tracker 15


If you are not familiar with the Serial interface then you can play around with this value until the tracker
remains still when a light is shined equally onto both sensors.

7. Making a single Axis Tracking Stand

here is a brief outline on the design along with some key pointers. Your stand should look something like this
when it is complete: but feel free to come up with a better design as well

Arduino Based Solar Tracker 16


The solar tracker in operation
Here is a video of the solar tracker in operation indoors with a torch being used to simulate the movement of
the sun

Arduino Solar Tracker


The operation of an Arduino based solar tracker. The tracker uses two LDRs and a PWM
servo to move a solar panel so that it is always facing the sun/light source. This was a test
using a torch as the light source.
https://youtu.be/5KljnLkbgB4

3. Building a Prototype
This is the final phase in which your creativity comes into play. The goal of this stage is to develop a product
that is well assembled and has aesthetic value. considering aesthetic while prototyping is a cruical part of
product development. presenting your work to stakeholders requires you not only understand the principle
behind your product but it should also be pleasing to the eye. With this in mind this final stage will be where
you the designers will use your imagination and creativity to bring out the potential of such kind of technologies
to public. We will see how we can well the wires into place and use MDF board to assemble all the
components. But do feel free to come up with ways to assemble them on your own.

Arduino Based Solar Tracker 17


Components required for this stage
1 x Arduino Uno

1 x Servo motor

1 x Solar panel

2 x LDR

2 x 10k Resistor

Jumper wires

1 x MDF board

Schematics and Connection of the Solar Tracker


The connection of the circuit is very straightforward. Here, we will use an Arduino Uno as controller and
connected the 2 LDRs to analogue pin A0 and A1 respectively. Pin 9 of Arduino is connected to the servo
motor. Since, we have used a 5V servomotor, we don’t require any external power supply because all the
components can easily be powered the Arduino itself. All the connections are shown in the figure below.

Arduino Based Solar Tracker 18


Step by Step procedure
1. The first step before assembling our solar tracker is to construct the base. For building the base, we are
going to use a MDF board. First step is to cut and make rectangular pieces of 128cm and 122cm from the
MDF board as shown in the figure.

Arduino Based Solar Tracker 19


2. Then stick 122cm piece vertically to the 128cm piece as shown in the image.

3. Next step is to attach the solar panel with the servo motor, for that we require the L-shaped contraption.
here we are using a plastic piece, you can also make this by bending a plastic sheet or aluminum sheet
and finally glue the solar panel to your contraption.

Arduino Based Solar Tracker 20


4. Now, we need to fix the LDRs on opposite sides of the solar panel and to do that, the LDRs are glued to
the panel. Then, the 10k resistors are connected to one any leads of both LDRs and the other side of
resistor should be connected to the ground. Second terminal of the LDRs are directly connected to the 5v
output. The output of each LDR, I connected it to A1 and A2 pins of Arduino.

5. Next step is to connect the servo motor, a servo motor has three wires, i.e. ground, V_in and a signal wire.
the V_in pin should be connected to the 5volt of Arduino, ground to the common ground and the signal
wire to pin-9 of Arduino. That's all about the circuit.

6. Now, all we have to do is assemble everything . First the Arduino is glued on the base sheet. Then the
servo motor is attached to the vertical section using glue gun. Finally the solar panel is fixed with the servo
motor’s hand and secured with a screw.

Arduino Based Solar Tracker 21


Code/Program

#include <Servo.h>
Servo servo ;

First, lets include the servo library and create a servo object and nameit as ‘servo’.

int eastLDR = 0;
int westLDR = 1;
int east = 0;
int west = 0;
int error = 0;

Here, we will assign the analogue pins AO and A1 pins for the LDR and declare the variables for sensor
values.

int calibration = 0;

This variable is for calibrating the system, if you are using exactly same LDRs on both sides then you can
leave it as zero. But if you are using different LDRs then you should use this to calibrate. To calibrate, follow
the instruction in next paragraph.

Serial print the sensor values and check the reading of each sensor in the noon or place a light source just
above the solar panel. If the reading shows the same values, then you can leave this as it is and if it shows
any difference, then you have to copy those values here.

int servoposition = 90;

This variable is used to store the servo position.

void setup()
{
servo.attach(9);
}

Servo pin defined as pin 9

east = calibration + analogRead(eastLDR);


west = analogRead(westLDR);

Arduino Based Solar Tracker 22


In the loop section, first step is to read the LDR values using the analogue read function of Arduino and store it
in east and west variables.

if(east<350 && west<350)


{
while(servoposition<=150)
{
servoposition++;
servo.write(servoposition);
delay(100);
}

This if condition is for turning the solar panel back to the east side, i.e. if both the LDRs read low value then
the panel moves towards the east side.

error = east - west;

Here, we calculate the difference between east and west readings. If the error value is positive that means
east has more intensity and if the error is negative then west has higher intensity of light. So, according to this
error value, we can rotate the servo to the low-intensity side.

if(error>30)
{
if(servoposition<=150)
{
servoposition++;
servo.write(servoposition);
}
}

If the error is positive and greater than 30, it means that the east side has more intensity. So, initially the
system will check the starting position of servo and if it is less than 150 degrees then it rotates to the east
direction. You can adjust these angles according to your system.

else if(error<-30)
{
if(servoposition>20)
{
servoposition--;
servo.write(servoposition);
}

If the error is negative and less than -30 that means the west side is more intense, hence servo rotates to the
west side.
So, that's all about coding. Now you can upload the sketch to the Arduino.

Arduino Based Solar Tracker 23


The compiled code can be copied from here

#include <Servo.h>

Servo servo ;

int eastLDR = 0;

int westLDR = 1;

int east = 0;

int west = 0;

int error = 0;

int calibration = 600;

int servoposition = 90;

void setup()

servo.attach(9);

Arduino Based Solar Tracker 24


void loop()

east = calibration + analogRead(eastLDR);

west = analogRead(westLDR);

if (east < 350 && west < 350)

while (servoposition <= 150)

servoposition++;

servo.write(servoposition);

delay(100);

error = east - west;

if (error > 15)

if (servoposition <= 150)

servoposition++;

servo.write(servoposition);

else if (error < -15)

if (servoposition > 20)

servoposition--;

servo.write(servoposition);

delay(100);

Video

Arduino Based Solar Tracker 25


How to Make Sun Tracking Solar Panel using Arduino
In this project, we will make a sun tracking system which will help the solar panels to
generate maximum power. Check out the full project tutorial:
https://circuitdigest.com/microcontroller-projects/building-your-own-sun-tracking-solar-panel-
https://youtu.be/KjYe_0tqvd8

Conclusion
I hope that you enjoyed this project. It has a lot of application in real life and it is implemented in a lot of solar
farms and individual solar harnessing setups. You can enhance the scope of this project by replacing the 5V
servo motor with a high torque servo motor and connect it using a relay and power the servo from an external
source. If you have bigger solar panels, then you will have to use stronger material such as aluminum for
base.

Congratulations on completing the project I hope this project sparked your interest in Arduino and solar
Trackers. We also believe that you have learned some new skills about Arduino. That’s awesome ! You might
have got a glimpse of how powerful Arduino can be and this will help you to keep on learning more about
different applications of Arduino. See you again with different project

Go make some ታRiC……

Arduino Based Solar Tracker 26

You might also like