How to make a solar tracking system using Arduino step by step
Hello and welcome back. In this project, we will learn how to make a simple DIY solar tracking system using Arduino. Also, it moves through the dual axis. I used one servo motor and two LDR sensors for that. If you want, you can expand it up to four axes.

What is a solar tracking system and how does it work?
These consist of three main parts. These are the single axis, dual-axis, and four-axis. Of these, dual-axis and single-axis are the main ones used. This method allows us to generate electricity through the sunlight at maximum efficiency. This is because the solar panel opens automatically toward sunlight. For that, the light-sensitive sensors are incorporated into these systems.

I also used two LDR sensors for this project. Usually, we can measure the light values using these sensors. If you want to learn what an LDR sensor is, you can use this link.
Ok, let’s do this project step by step. The required components are given below.
- Arduino UNO board x 1 — Our Store / Amazon
- Solar panel x 1 — Amazon
- SG90 servo motor x 1 — Our Store / Amazon
- LDR sensor x 2 — Our Store / Amazon
- 10k resistor x 2 — Our Store / Amazon
- Jumper wires — Our Store / Amazon
- Rigifoam — Amazon
- Foam board — Amazon
- Cardboard — Amazon
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
Firstly, identify these components.







Step 2
Secondly, cut the base part of the project. To do this, use the following sizes.

Step 3
Thirdly, attach the following pieces to the base part.





Step 4
Then, attach the servo motor. For that, use the pictures below.


Step 5
Next, attach two pieces of rigifoam to the solar panel. After, attach an iron stick to one side of the solar panel.




Step 6
Now, connect one side of it to the servo motor and the other side to the rigifoam piece.



Step 7
Then, solder the 10k resistor to one leg of the LDR. Also, solder this way for both sensors.


Step 8
Next, solder these sensors together. For that, use the circuit diagram below.




Step 9
Afterward, solder the two jumper wires to the voltage divider points of these sensors. Please look at the circuit diagram above.


Step 10
Now, solder the 5v and GND jumper wires.


Step 11
Then, connect these sensors to both sides of the solar panel.



Step 12
Next, mount the Arduino board and connect the LDR sensors and servo motor to it. You can use the circuit diagram above for that.


Step 13
Now, connect this project to your computer and upload the following program. It is as follows.

- The full program of this project — Download
/*Solar tracking system
Home Page
*/
//Include the servo motor library
#include <Servo.h>
//Define the LDR sensor pins
#define LDR1 A0
#define LDR2 A1
//Define the error value. You can change it as you like
#define error 10
//Starting point of the servo motor
int Spoint = 90;
//Create an object for the servo motor
Servo servo;
void setup() {
//Include servo motor PWM pin
servo.attach(11);
//Set the starting point of the servo
servo.write(Spoint);
delay(1000);
}
void loop() {
//Get the LDR sensor value
int ldr1 = analogRead(LDR1);
//Get the LDR sensor value
int ldr2 = analogRead(LDR2);
//Get the difference of these values
int value1 = abs(ldr1 - ldr2);
int value2 = abs(ldr2 - ldr1);
//Check these values using a IF condition
if ((value1 <= error) || (value2 <= error)) {
} else {
if (ldr1 > ldr2) {
Spoint = --Spoint;
}
if (ldr1 < ldr2) {
Spoint = ++Spoint;
}
}
//Write values on the servo motor
servo.write(Spoint);
delay(80);
}
Step 14
Finally, select board and port. After, upload this code to the Arduino board.
Ok, enjoy this project. The full video guide is below. So see you in the next project.
How to make a solar tracking system using Arduino
/*Solar tracking system
https://srituhobby.com
*/
//Include the servo motor library
#include
//Define the LDR sensor pins
#define LDR1 A0
#define LDR2 A1
//Define the error value. You can change it as you like
#define error 10
//Starting point of the servo motor
int Spoint = 90;
//Create an object for the servo motor
Servo servo;
void setup() {
//Include servo motor PWM pin
servo.attach(11);
//Set the starting point of the servo
servo.write(Spoint);
delay(1000);
}
void loop() {
//Get the LDR sensor value
int ldr1 = analogRead(LDR1);
//Get the LDR sensor value
int ldr2 = analogRead(LDR2);
//Get the difference of these values
int value1 = abs(ldr1 – ldr2);
int value2 = abs(ldr2 – ldr1);
//Check these values using a IF condition
if ((value1 <= error) || (value2 ldr2) {
Spoint = –Spoint;
}
if (ldr1 < ldr2) {
Spoint = ++Spoint;
}
}
//Write values on the servo motor
servo.write(Spoint);
delay(80);
}