Arduino Projects

How to make a Solar Tracker using Arduino, Arduino solar Tracker system its circuit and programming

Arduino Solar tracker Project Description:

 

Arduino Solar Tracker- In this tutorial, you will learn how to make your own Arduino based solar tracking system. This solar tracker project is based on Arduino, LDR, and H-bridges. The LDR’s will be used for sunlight sensing. In this tutorial, I will discuss everything

  1. Arduino Solar Tracker Complete circuit diagram
  2. Step by Step soldering
  3. Complete interfacing
  4. step by step Arduino Solar Tracker program explanation
  5. Finally testing.

Today the solar trackers are used throughout the world, the solar tracker that we are going to make today is best as it’s cheap and is able to rotate heavy panels as we will be using the relays, and as you know relays can bear larger currents. We will be making our own H-bridge to control the direction of the dc gear motor.


Amazon Links:

12v Adaptor:

Arduino Uno

Arduino Nano

Mega 2560:

Car Wiper 12V gear Motor

1n4007 diode:

10k Resistor:

2n2222 NPN transistor

12V SPDT Relay:

LM741 OpAmp:

LDR “light dependent resistor”:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Arduino Solar Tracker Circuit Diagram:

Arduino Solar Tracker Circuit Diagram

In the above circuit, the LM741 Operational Amplifier is used as the voltage comparator. The LDR “Light Dependent Resistor” is connected in series with a 10 kilo Ohm resistor. The LDR and 10k resistor makes a voltage divider circuit. As the amount of light falling on the LDR changes so the resistance changes due to which we get variable voltage. The resistance of the LDR changes with the amount of light falling on the LDR. As you can wire from the middle of the LDR and 10k resistor is connected with the Inverting input pin of the LM741 Op-Amp IC.

The voltage which is fed to the Inverting input of the LM741 IC is compared with the voltage which is coming from the R3 which is a 100K variable resistor. This variable resistor is used to set the reference voltage on the Non-inverting input of the LM741 Op-Amp IC. Two 470 Ohm resistors are connected in series with the 100k variable resistor, which protects the circuit from the short circuit.

We have to voltages to compare, one voltage is coming to form the LDR and the other is the reference voltage set by the potentiometer or variable resistor.

V1 = Reference voltage which is coming from the Variable resistor.

V2 = the voltage coming from the LDR.

V1 and V2 will be compared using the LM741. The output of the LM741 will be High if

V1 > V2 and the output will be low if V1 < V2.

The V2 varies as the amount of light varies so when there is light it will have one state and when there is no light then it will have another state. This way we can know if the light from the Sun is falling on the LDR.

When V1 > V2 the output get High, and at the output, we get voltage which is approximately equal to the input supply voltage which in our case is 12 volts. The output voltage of the LM741 IC is not exactly 12 volts it can be around 10 to 11 volts. So when the output is high we get around 12 volts.

At this point, we are able to differentiate between the “two states, Light is falling on the LDR or not” and accordingly we get 0 volts and 11 volts approximately. Now the next step is to use this output voltage to control a Relay which can be used to give signals to the controller. But if you look at the datasheet you will find that the output current of the LM741 IC is 25milliamps which is not enough to turn on a 12v relay. The relay I have used in this circuit needs around 32milliamps. So it means we will need some kind of driver to control the relay.

We can use a transistor with the LM741 IC. As you can see in the circuit diagram I have used a 2n2222 NPN transistor. Now if you look at the datasheet of the 2n2222 NPN transistor you will find the 2n2222 base voltage should not exceed 6 volts. If you apply voltage greater than 6 volts it will damage the 2n2222 NPN transistor.

As we know the output voltage of the LM741 IC is around 12 volts when in ON state so if this voltage is directly connected with the base of the 2n2222 NPN transistor it will completely damage the transistor. Now to solve this problem we will need to use a voltage divider to reduce the voltage. so that’s the reason I used 10k and 1k resistors in series. This the base voltage never exceeds 6 volts. Now we can turn ON and Turn OFF the 2n2222 NPN transistor without any problem. The transistor will be used to control the 12v relay. This relay is of the type SPDT “Single Pole Double Throw”.

In the circuit diagram above you can see, I have used two LM741 Op-Amp ICs. These two circuits are used together to decide, in which direction the solar Panel needs to be rotated. The outputs from the relays are connected with the i/o pins of the controller Atmega328. You can also use the Arduino board if you don’t want to make your own board.

On the left side you can see a motor which is controlled using an H-bridge. The H-bridge itself is a whole new topic and i have a very detailed tutorial on the H-bridge designing.

Download:

Atmega328 PCB board file: atmega328 board

Download:

Relay H-Bridge PCB board file: relay bridge

These PCB “Printed Circuit Board” files can be opened in Cadesoft Eagle 9.1.0 Version.


Arduino Solar Tracker Programming:

Solar tracker Programming

int ldr1 = 2;
int ldr2 = 4;

int right = 7;
int left = 8;

void setup()
{
pinMode(ldr1, INPUT);
pinMode(ldr2, INPUT);
Serial.begin(9600);
pinMode(right, OUTPUT);
pinMode(left, OUTPUT);
  
}

void loop()
{
 if((digitalRead(ldr1) == LOW)&&(digitalRead(ldr2)==HIGH))
{
  Serial.println("right");
 digitalWrite(right, HIGH);
 digitalWrite(left, LOW);
 delay(100);

} 
 if((digitalRead(ldr1) == HIGH)&&(digitalRead(ldr2)==LOW))
{
  Serial.println("left");
 digitalWrite(right, LOW);
 digitalWrite(left, HIGH);
 delay(100);

} else
digitalWrite(ldr1, HIGH);
digitalWrite(ldr2, HIGH);
Serial.println("stop");
digitalWrite(left, LOW);
digitalWrite(right,LOW);
}


Arduino Solar Tracker Code Explanation:

The output of the two circuits based on the LM741 Op-Amps ICS are connected with the Arduino’s pins 2 and 4. These pins are used to detect if the light is falling on the ldr1, or if the light is falling on the ldr2, or if the light is falling on both the LDRs, or if the light is not falling on any of the LDRs.

int ldr1 = 2;
int ldr2 = 4;

The two relays in an H-bridge are controlled using the Arduino’s pins 7 and 8.

int right = 7;
int left = 8;

void setup()
{
pinMode(ldr1, INPUT); // set as input
pinMode(ldr2, INPUT); // set as input
Serial.begin(9600); // activates the Serial communication and 9600 is the baud rate.
pinMode(right, OUTPUT);// relay is set to output
pinMode(left, OUTPUT);// relay is set to output

}

void loop()
{

this condition is checks if the light is only falling on one ldr, then rotate the solar panel
if((digitalRead(ldr1) == LOW)&&(digitalRead(ldr2)==HIGH))
{
Serial.println(“right”);
digitalWrite(right, HIGH);
digitalWrite(left, LOW);
delay(100);

}

this condition checks if the light is falling on the other ldr, then rotate the solar panel in the opposite direction.
if((digitalRead(ldr1) == HIGH)&&(digitalRead(ldr2)==LOW))
{
Serial.println(“left”);
digitalWrite(right, LOW);
digitalWrite(left, HIGH);
delay(100);

} else
digitalWrite(ldr1, HIGH);
digitalWrite(ldr2, HIGH);
Serial.println(“stop”);
digitalWrite(left, LOW);
digitalWrite(right,LOW);
}

Arduino Solar Tracker, Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

3 Comments

  1. Hi Engr,
    I have seen plenty of designs for trackers and this one is both elegant and simple.
    I will implement the tracker as soon as I am finished with the mechanical construction
    of my panels onto their frame etc.
    Kind Regards,
    Toby.

  2. Hi there, is there anything I can add to the code to have the solar panel to return to the east direction after the Sun sets? And how far apart do the LDRs need to be? Thanks for the great design and simple coding.

  3. Is there anything that can be added to the code to reset the panel to the East if both LDRs are reading darkness? I try to add another “if, else” to the code but it conflicted. It seems that if both can read “HIGH” and cause the actuator to stop, can both read “LOW” and get the panel to return East before Sunrise the next day?

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button