Making a Sun Tracking Solar Panel

A guide to make our solar panels more efficient ☀️

Avantika Chaturvedi
5 min readJun 13, 2021
Photo by Nuno Marques on Unsplash

“A solar panel’s efficiency is generally around 15–20%”

That doesn’t sound the greatest does it? I mean considering that we want to use these same solar panels to power the future generation that stat should make most of us feel a bit nervous. It sure made me nervous — and although there is work being done in this space to improve our solar panels I couldn’t help but want to do something about this problem myself. So that’s exactly what I did, by making my own solar panel sun tracker!

You did what?

Solar panel sun tracker. Phew that was a mouthful, but to simplify it what I wanted to do was make a system that would make a solar panel change directions based on where there was more light coming. Currently our solar panels are stationary so obviously if there is light coming from the opposite direction there’s not really much they can do about it. But using some really cool sensors and my Arduino Uno, I was actually able to make this vision a reality, and if you’re reading this then you’re also going to be taken on a step by step journey on how exactly this happened.

What you’ll need

If you are considering following along this article or are simply just curious, here is the list of things I used for this project:

  • An Arduino (Uno used here) — Buy Here
  • 2 x 4.7K Resistors — Buy Here
  • A mini solar panel (Available on amazon)
  • 2 x LDRs — Buy Here
  • A breadboard
  • PWM Servo — Buy Here
  • LOTS of jumper wires :)

Getting started

First we need to start by assembling the components onto our breadboard. 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.

Wait what’s a LDR? LDRs (light-dependent resistors) are used to detect light levels, for example, in automatic security lights. Their resistance decreases as the light intensity increases: in the dark and at low light levels, the resistance of an LDR is high and little current can flow through it. In bright light, the resistance of an LDR is low and more current can flow through it. These are what we will be using to measure which direction there is more sunlight and use this information to control our solar panel.

Assembling the components

If you are going to be installing the solar tracker permanently then you may want to solder the resistors and LDRs together so that they cannot come loose. If you are simply trying this project for fun then a breadboard is perfect. For my case, I used a breadboard which worked well for me. This is how we need to wire our project. Now this might look a bit complicated (it sure did to me as I am also still learning about circuits!) but don’t worry I will be releasing a video showing a step by step tutorial on how to assemble this!

This is how your wiring should look like

The servo also 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.

How the solar panel should be mounted on the servo

Now you're probably wondering where on earth the solar panel comes in, like where are we supposed to put it? If I am being honest this might have been the part I was stumped on the most, as I had no clue how I was supposed to incorporate that thing into my set up. Turns out this part did not require so much overthinking, I simply needed to mount the solar panel onto the servo.

The Code

NOTE: I will be going over the code in detail in my video coming out about this project but there are comments to help you follow along

#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
{
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);
}

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.

Results!

Here is a short clip of how the project turned out — make sure to run your code on arduino before expecting any results 😉

My moving solar panel!

Let’s Connect!

Feel free to contact me at avantikachat@gmail.com, or connect with me on my Linkedin. If you would like to receive monthly updates about what I’ve been up to and my future articles subscribe to my newsletter here!

If you liked the is article be sure to check out the one I wrote explaining IoT on a deeper level here.

--

--