Electronic projects

[Electronic projects][bleft]

Arduino Projects

[Arduino Projects][bleft]

Metal detectors

[Metal detectors][bleft]

Home projects

[Home projects][bleft]

Arduino smart solar panel for tracking sunlight

 

The biggest crisis we face today is climate change caused by the excessive use of fossil fuels. To overcome these problems, we have only one solution that is to use renewable energy. Renewable energy is a kind of energy obtained from nature and will not cause adverse effects on the environment. The most prominent type of renewable energy is solar energy. The radiation from the sun is collected by solar panels and converted into electrical energy. The output power depends on the amount of sunlight falling on the solar panel.


Traditionally, solar panels are fixed, and the movement of the sun on the horizon means that solar panels cannot use the maximum energy most of the time. In order to maximize the power of solar panels, the panels should always face the sun. In this article, we will make a sun tracking system to help solar panels generate maximum energy.

How does the solar tracker work?

You must be wondering how it works? As mentioned earlier, solar panels should face the sun to utilize maximum power. Therefore, our system has two steps. The first is to detect the position of the sun, and the second is to follow the sun.

Detect the position of the sun:

We use Arduino to measure the light intensity of the LDR, and then compare the light intensity falling on the two LDRs. The LDR is placed on the edge of the solar panel, as shown in the figure below.


According to the light intensity on the LDR, we send a signal to the servo motor to cause work. When the intensity of light falling on the right LDR is high, the solar panel rotates to the right, and if the intensity of the left side is high, the solar panel rotates to the left.

 


Suppose that on a beautiful winter morning, the sun rises from the east, so the light intensity in the east is greater than in the west, so the solar panels move to the east. It will track the sun during the day, and at night, the sun has moved westward, so the intensity of the west will be greater than that of the east, so the solar panels will face west.


Required components

● Arduino Uno development board

● Servo motor

● Solar panels

● LDR photoresistor

● Connecting wires

● 10K resistance


Servo motors are used to rotate solar panels. We use a servo motor because it can precisely control the position of the solar panel and it can cover the entire light path.


Photoresistor (LDR):

Light Dependent Resistor ( Light Dependent Resistor ) is made of semiconductor material with photosensitive characteristics, so it is very sensitive to light. The resistance of the LDR changes according to the light falling on it and is inversely proportional to the light intensity. In other words, the resistance of the LDR will increase under high-intensity light, and vice versa.


Schematic diagram of the sun tracker

The connection of the circuit is very simple. This article uses the Arduino Uno development board as the controller, and connects 2 LDRs to the analog pins A0 and A1 respectively. Pin 9 of the Arduino is connected to the servo motor. Because, we use a 5V servo motor, so no external power supply is needed, and all components can be easily powered by Arduino. All connections are shown in the figure below.

 


Assemble the solar tracker

The first step before assembling our solar tracker is to make the base. To make the base, I will use MDF fiberboard. The first step is to cut and make rectangular blocks of 12*8cm and 12*2cm from the MDF board, as shown in the picture.

Then paste a piece of 12 * 2cm vertically to a piece of 12 * 8cm, as shown in the picture.


The next step is to connect the solar panel with the servo motor, for which we need an L-shaped device. For this, I used a piece of plastic and finally glued the solar panel to your device.



Now, we need to stick the LDR on both sides of the solar panel. Then, connect the 10k resistor to either end of the two LDRs, and the other side of the resistor should be grounded. They act as pull-down resistors. The second terminal of the LDR is directly connected to the 5v output. The output of LDR, connect it to the A1 and A2 pins of Arduino.



The next step is to connect the servo motor. The servo motor has three wires, namely ground, V_in and signal wires. Connect the V_in pin to the 5V of the Arduino, the ground to the common ground, and the signal wire to the 9 pin of the Arduino.

Now, all we have to do is to assemble all the components. First, glue the Arduino to the base. Then use a glue gun to connect the servo motor to the vertical part. Finally, fix the servo motor to the solar panel and fix it with screws.

Code description

Before writing the code, you first need to download the servo motor library. We need a servo motor hangar to control the movement of the servo motor. The procedure is described in detail below.

  1. #include <Servo.h>
  2. Servo servo;
Copy code

First, the header file of the servo library is included, and a servo object is created and named "servo".

  1. int eastLDR = 0;
  2. int westLDR = 1;
  3. int east = 0;
  4. int west = 0;
  5. int error = 0;
Copy code

In this paper, the LDR is connected to the analog pins A0 and A1, and then the variables related to the sensor value are declared.

  1. int calibration = 0;

Copy code

This variable is used to calibrate the system, if you use exactly the same LDR on both sides, you can set it to zero. But if you use a different LDR, then you should use it to calibrate.

The serial port prints the sensor value, and then check the reading of each sensor at noon or place a light source directly above the solar panel. If the readings show the same values, you can leave them as they are, and if they show any differences, you must copy those values ​​here.

  1. int servoposition = 90;
Copy code

This variable is used to store the position of the servo.

  1. void setup()
  2. {
  3.   servo.attach(9);
  4. }
Copy code

In this section, the servo motor pin is defined as pin 9.


  1. east = calibration + analogRead(eastLDR);  
  2. west = analogRead(westLDR);
Copy code

In the loop() function, first use the Arduino analogRead() function to read the LDR value and store it in the variables east and west.

  1. if(east<350 && west<350)
  2.   {
  3. while(servoposition<=150)
  4.   {
  5. servoposition++;
  6. servo.write(servoposition);
  7. delay(100);
  8.     }
Copy code

The if condition is to turn the solar panel back to the east, that is, if both LDRs read low values, the panel moves to the east.

  1. error = east-west;
Copy code

Here, we calculate the error between the east and west readings. If the error value is positive, it means the east has a higher intensity, if the error value is negative, the west has a higher light intensity. Therefore, according to this error value, we can rotate the steering gear to the low-intensity side.

  1. if(error>30)
  2.   {
  3. if(servoposition<=150)
  4. {
  5. servoposition++;
  6. servo.write(servoposition);
  7. }
  8.   }
Copy code

If the error is positive and greater than 30, it means that the east side is stronger. The system will check the starting position of the steering gear, and if it is less than 150 degrees, it will rotate to the east. You can adjust these angles according to your system.

  1. else if(error<-30)
  2.   {
  3. if(servoposition>20)
  4. {
  5. servoposition--;
  6. servo.write(servoposition);
  7.   }
Copy code

If the error is negative and less than -30, it means that the light on the west side is stronger, so the servo motor rotates to the west.

The above is the code part of this article. Now you can open this code on Arduino IDE and upload it to Arduino.

Hope you like this project. It has many applications in real life and is implemented in many solar power stations and personal solar energy utilization settings. You can expand the application scope of this project by replacing the 5V servo motor with a large torque servo motor, or connecting it with a relay, and supplying the servo from an external power supply. If you encounter any problems, please feel free to reply below this post.

 


 

Arduino Projects

[Arduino Projects][twocolumns]