Arduino Based Solar Tracker
Arduino Based Solar Tracker
Arduino Based Solar Tracker
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.
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
💡 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
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.
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
1 x MDF board
We will now take a look about some of the main components in detail
Servo motor
💡 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
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.
3. Resistors 10K – 2
4. LDR – 2 Nos
5. Breadboard
6. Connecting Wires
Circuit Diagram
The circuit diagram for the Arduino based solar tracker is given below . Assemble the circuit as shown below
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
#include <Servo.h>
void loop() {
//float volt1=sensorValue*(5.0/1023.0);
//float volt2=sensorValue1*(5.0/1023.0);
int error=abs(volt1 - volt2);
}
if (volt2 > volt1){
myservo.write(135);
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
3. Resistors 2 x 4.7k
4. LDR x 2
5. Breadboard
6. Connecting Wires
Circuit Diagram
The circuit diagram for the Arduino based solar tracker is given below . Assemble the circuit as shown below
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.
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>
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
{
💡 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 ?
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,
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.
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
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.
1 x Servo motor
1 x Solar panel
2 x LDR
2 x 10k Resistor
Jumper wires
1 x MDF board
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.
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.
#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.
void setup()
{
servo.attach(9);
}
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.
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.
#include <Servo.h>
Servo servo ;
int eastLDR = 0;
int westLDR = 1;
int east = 0;
int west = 0;
int error = 0;
void setup()
servo.attach(9);
west = analogRead(westLDR);
servoposition++;
servo.write(servoposition);
delay(100);
servoposition++;
servo.write(servoposition);
servoposition--;
servo.write(servoposition);
delay(100);
Video
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