Original address: https://circuitdigest.com/microcontroller-projects/arduino-solar-panel-tracker
Use Arduino's solar tracking solar panels
Pass by** Muhammad Aqib **January 12, 2017 25
Arduino based Sun Tracking Solar Panel project using LDR and servo motor
In this paper, we will use Arduino to make a solar tracking solar panel, in which we will use two ldrs (light dependent resistors) to sense light, and use a servo motor to automatically rotate the solar panel in the direction of sunlight. The advantage of the project is that the solar panel will always follow the sun, always face the sun to maintain the state of charge, and can provide maximum power for the power supply. The prototype is very easy to build. Below, you will find a complete description of how it works and how the prototype is manufactured.
Required components of Arduino Solar Tracker:
The following are the components needed to build a solar tracking system using Arduino, most of which should be available in your local store.
- Servo motor (SG90)
- Solar panels
- Arduino Uno
- X 2 of LDR (photoresistor)
- 10K resistor X 2
- Battery (6 to 12V)
How does the single axis solar tracker work?
In this project, LDR is used as a photodetector. Before going into detail, we will have to understand how LDR works** LDR (photosensitive resistance) * * also known as photosensitive resistance, is a photosensitive device. When light falls on it, its resistance decreases, which is why it often falls on it Dark or light detector circuit Reasons for use . Here inspect Based on LDR Various Circuit.
Two ldrs are placed on both sides of the solar panel, while servo motor For rotating solar panels. The server will move the solar panel towards the LDR with lower resistance, that is, towards the LDR with falling light, so that it will always follow the light. If there is a small amount of light on both ldrs, the server will not rotate. The server will try to move the solar panel to a position where both ldrs have the same resistance, which means that the amount of light on both resistors will be the same. If the resistance of one LDR changes, it will rotate the LDR towards the lower resistance. Check out the demo video at the end of this article.
How to use Arduino to build a rotating solar panel:
To prototype, you will have to perform the following steps:
Step 1:
First, take a small piece of cardboard and punch a hole in one end. Later, we insert the screw into it to secure it with the server.
Step 2:
Now, with the help of glue or a hot-air gun, fix the two small pieces of cardboard to each other in a V shape, and then place the solar panel on it.
Step 3:
Then connect the V-shaped bottom surface to the other end of the small paperboard, and punch a hole in the small paperboard in the first step.
Step 4:
Now, insert the screw into the hole you made on the card board and insert it into the server through the hole. When purchased, the servo motor comes with screws.
Step 5:
Now, place the server on another piece of cardboard. The size of the cardboard should be large enough so that you can place Arduino Uno, bread board and battery on it.
Step 6:
Fix the LDR on both sides of the solar panel with glue. Make sure you have welded the wires to the feet of the LDR. Later, you will have to connect them to resistors.
Step 7:
Now, place the Arduino, battery and bread board on the cardboard and connect them as described in the "circuit diagram" and "description" below. The final prototype is shown below.
Circuit diagram and Description:
The complete circuit diagram of the solar tracking arduino project is shown below. As you can see, the circuit is very simple and can be easily built with the help of a small bread board.
In this Arduino Solar Panel Tracker, the Arduino is powered by a 9V battery, while all other components are powered by Arduino. Arduino recommends an input voltage of 7 to 12 volts, but you can supply it in the range of 6 to 20 volts (this is the limit). Try to power it within the recommended input voltage range. Therefore, connect the positive wire of the battery to Vin of Arduino and the negative wire of the battery to ground of Arduino.
next, Connect the steering gear to Arduino . Connect the positive line of the Servo to the 5V of the Arduino, connect the ground wire to the ground wire of the Arduino, and then connect the signal line of the Servo to the digital pin 9 of the Arduino. The server will help move the solar panels.
Now connect the LDR to Arduino. Connect one end of LDR to one end of 10k resistor, then connect this end to A0 of Arduino, then ground the other end of the resistor, and connect the other end of LDR to 5V. Similarly, connect one end of the second LDR to one end of another 10k resistor, connect that end to A1 of Arduino, ground the other end of the resistor, and connect the other end of the LDR to the other end of 5V Arduino.
Single axis solar tracker using Arduino Code:
The code of Solar Panel Tracker based on Arduino is very simple and well explained by comments. First, we will include the servo motor library. Then, we will initialize the variable of the initial position of the servo motor. After that, we will initialize the variables to read from the LDR sensor and servo.
#include <Servo.h> //including the library of servo motor Servo sg90; //initializing a variable for servo named sg90 int initial_position = 90; //Declaring the initial position at 90 int LDR1 = A0; //Pin at which LDR is connected int LDR2 = A1; //Pin at which LDR is connected int error = 5; //initializing variable for error int servopin=9;
*sg90. The atach (servopin) * command reads Servo from pin 9 of Arduino. Next, we set the LDR pin as the input pin so that we can read the value from the sensor and move the solar panel accordingly. Then, set the Servo motor to 90 degrees, which is the initial position of the Servo.
void setup() { sg90.attach(servopin); // attaches the servo on pin 9 pinMode(LDR1, INPUT); //Making the LDR pin as input pinMode(LDR2, INPUT); sg90.write(initial_position); //Move servo at 90 degree delay(2000); // giving a delay of 2 seconds }
Then, we will read the value from LDR and save it in R1 and R2. Then, we will make the difference between the two ldrs to move the server accordingly. If the difference between them is zero, it means that the amount of light on the two ldrs is the same, so the solar panel will not move. We use a variable named error with a value of 5. The purpose of this variable is that if the difference between two ldrs is less than 5, the servo will not move. If we don't, the servo will continue to rotate. If the difference is greater than the error value (5), the server will move the solar panel in the LDR direction, and the light will move in this direction in the LDR direction. Check out the complete code and demo video below.
int R1 = analogRead(LDR1); // reading value from LDR 1 int R2 = analogRead(LDR2); // reading value from LDR 2 int diff1= abs(R1 - R2); // Calculating the difference between the LDR's int diff2= abs(R2 - R1); if((diff1 <= error) || (diff2 <= error)) { //if the difference is under the error then do nothing } else { if(R1 > R2) { initial_position = --initial_position; //Move the servo towards 0 degree } if(R1 < R2) { initial_position = ++initial_position; //Move the servo towards 180 degree } }
In this way, you can build a simple Solar Panel Tracker, which will automatically move towards the light like a sunflower. Here, we use low-power solar panels to reduce weight. If you intend to use high-power or heavy-duty solar panels, you need to select the servo motor accordingly.
code
/* Arduino solar tracker code www.circuitdigest.com */ #include <Servo.h> //including the library of servo motor Servo sg90; //initializing a variable for servo named sg90 int initial_position = 90; //Declaring the initial position at 90 int LDR1 = A0; //Pin at which LDR is connected int LDR2 = A1; //Pin at which LDR is connected int error = 5; //initializing variable for error int servopin=9; void setup() { sg90.attach(servopin); // attaches the servo on pin 9 pinMode(LDR1, INPUT); //Making the LDR pin as input pinMode(LDR2, INPUT); sg90.write(initial_position); //Move servo at 90 degree delay(2000); // giving a delay of 2 seconds } void loop() { int R1 = analogRead(LDR1); // reading value from LDR 1 int R2 = analogRead(LDR2); // reading value from LDR 2 int diff1= abs(R1 - R2); // Calculating the difference between the LDR's int diff2= abs(R2 - R1); if((diff1 <= error) || (diff2 <= error)) { //if the difference is under the error then do nothing } else { if(R1 > R2) { initial_position = --initial_position; //Move the servo towards 0 degree } if(R1 < R2) { initial_position = ++initial_position; //Move the servo towards 180 degree } } sg90.write(initial_position); // write the position to servo delay(100); }