Skip to Content

SUN TRACKING SYSTEM

The Sun Tracking System is an innovative and efficient solution designed to maximismaximise solar energy absorption by automatically adjusting the position of a solar panel to follow the sun's movement across the sky. At the heart of this system are Light Dependent Resistor (LDR) sensors, which detect variations in sunlight intensity and direction. These sensors are strategically placed to measure light levels on different sides of the solar panel, providing real-time data about the sun's position. Based on the input from the LDR sensors, the system uses servo motors to precisely tilt and rotate the solar panel, ensuring it remains perpendicular to the sun's rays throughout the day. This dynamic adjustment significantly enhances the panel's energy capture efficiency, making it far more effective than fixed-position solar panels. The system is controlled by a microcontroller, such as an Arduino, which processes the sensor data and sends commands to the servo motors. Beyond small-scale applications, this technology can be scaled up for use in large solar farms, where optimizing energy capture is critical for maximizing output. By combining simple yet effective components like LDR sensors, servo motors, and microcontrollers, the Sun Tracking System offers a cost-effective and sustainable way to improve the performance of solar power systems, making it an ideal solution for both residential and industrial solar energy applications.

Components Required

  • Arduino Uno
  •  Light Dependent Resistors (LDRs)
  • 10kΩ Resistors
  • Servo Motors
  • Solar Panel
  • Jumper Wires
  • Breadboard
  • Power Supply

Circuit Diagram

  1. Connect the LDR Sensors (Voltage Divider Circuit)
      1. ∙ LDR 1 (Left Side):
        • One leg → 5V on Arduino
        • Other leg → A0 on Arduino & one leg of a 10kΩ resistor
        • Other leg of 10kΩ resistor → GND on Arduino
      2. ∙ LDR 2 (Right Side):
        • One leg → 5V on Arduino
        • Other leg → A1 on Arduino & one leg of a 10kΩ resistor
        • Other leg of 10kΩ resistor → GND on Arduino

​LDRs detect light intensity and send signals to the Arduino, allowing it to determine the brighter side.

2. Connect the Servo Motor

      1. Servo VCC (Red Wire) → 5V on Arduino
      2. Servo GND (Black/Brown Wire) → GND on Arduino ∙ 
      3. Servo Signal (Yellow/Orange Wire) → D9 on Arduino

     The servo motor rotates the solar panel toward the brighter LDR.

3. Power the System

4. Upload the Code

CODE

#include <Servo.h>

#define LDR_LEFT A0

#define LDR_RIGHT A1

#define SERVO_PIN 9


Servo solarTracker;


void setup() {

​ solarTracker.attach(SERVO_PIN);

​ pinMode(LDR_LEFT, INPUT);

​ pinMode(LDR_RIGHT, INPUT);

​ Serial.begin(9600);

}


void loop() {

​ int leftLight = analogRead(LDR_LEFT);  int rightLight = analogRead(LDR_RIGHT);

​ Serial.print("Left LDR: ");

​ Serial.print(leftLight);

​ Serial.print(" | Right LDR: ");

​ Serial.println(rightLight);

​ int position = solarTracker.read();


​ if (leftLight > rightLight + 50) {

​position = constrain(position + 2, 0, 180); 

​ }

​ else if (rightLight > leftLight + 50) { 

​ position = constrain(position - 2, 0, 180); 

​ }

​ solarTracker.write(position);

​ delay(100);

}


CODE EXPLANATION

  1. Libraries and Pin Definitions
#include <Servo.h> 
#define LDR_LEFT A0
#define LDR_RIGHT A1
#define SERVO_PIN 9

  • Servo.h: Enables control of the servo motor.
  • LDR_LEFT: Pin connected to the left LDR sensor (analog input).
  • LDR_RIGHT: Pin connected to the right LDR sensor (analog input).
  • SERVO_PIN: Pin connected to the servo motor (digital PWM output).

    2. Object Initialization

Servo solarTracker; 
  • solarTracker: An object of the Servo class to control the servo motor.

   3. Setup Function

void setup() { 
  solarTracker.attach(SERVO_PIN);
  pinMode(LDR_LEFT, INPUT);
  pinMode(LDR_RIGHT, INPUT);
  Serial.begin(9600);
}
  • solarTracker.attach(SERVO_PIN): Attaches the servo motor to the specified pin.
  • pinMode(): Configures the LDR pins as inputs to read light intensity.
  • Serial.begin(9600): Initializes serial communication for debugging.

4.  Loop Function

void loop() { 
  int leftLight = analogRead(LDR_LEFT); 
  int rightLight = analogRead(LDR_RIGHT);
  • analogRead(LDR_LEFT): Reads the light intensity from the left LDR sensor.
  • analogRead(LDR_RIGHT): Reads the light intensity from the right LDR sensor.

 5. Debugging Output

  Serial.print("Left LDR: "); 
  Serial.print(leftLight);
  Serial.print(" | Right LDR: ");
  Serial.println(rightLight);
  • Prints the light intensity values from both LDR sensors to the Serial Monitor for debugging.

    6. Servo Position Adjustment Logic

  int position = solarTracker.read(); 
  if (leftLight > rightLight + 50) {
    position = constrain(position + 2, 0, 180); 
  } else if (rightLight > leftLight + 50) { 
    position = constrain(position - 2, 0, 180); 
  }
  solarTracker.write(position);
  • solarTracker.read(): Reads the current position of the servo motor.
  • Adjustment Logic:
    • If the left LDR detects significantly more light (leftLight > rightLight + 50), the servo motor moves 2 degrees to the right (position + 2).
    • If the right LDR detects significantly more light (rightLight > leftLight + 50), the servo motor moves 2 degrees to the left (position - 2).
    • constrain(): Ensures the servo position stays within the range of 0 to 180 degrees.
  • solarTracker.write(position): Updates the servo motor position.

    7. Delay 

  delay(100); 
}
  • Adds a 100ms delay to stabilize the system and prevent rapid, unnecessary adjustments.

  8. Key Features

  • Light Detection: Uses LDR sensors to measure sunlight intensity on both sides of the solar panel.
  • Dynamic Adjustment: Moves the servo motor in small increments (2 degrees) to align the panel with the sun.
  • Debugging: Prints LDR values to the Serial Monitor for real-time monitoring.
  • Safety: Ensures the servo motor stays within its operational range (0–180 degrees).

  Example Workflow

  1. Initial State:
    • The solar panel is at a default position (e.g., 90 degrees).
  2. Light Detection:
    • The left LDR detects more light than the right LDR.
  3. Servo Adjustment:
    • The servo motor moves the panel 2 degrees to the right.
  4. Continuous Tracking:
    • The system continuously adjusts the panel based on real-time LDR readings.
  5. Debugging:
    1. The Serial Monitor displays the LDR values and helps troubleshoot issues.

TESTING THE SYSTEM 

  1. Place the system in a bright area. 
  2. Shine a flashlight on one LDR and observe the panel move toward the light. 
  3. Move the flashlight to the other LDR, and the panel should adjust accordingly. 
  4. The serial monitor will show real-time LDR values. 

COMMON PROBLEMS AND SOLUTIONS

  • Servo Not Moving? 
    • Ensure correct pin connections and Servo.h library is installed. 
  • Panel Not Tracking the Light? 
    • Test LDR values using Serial Monitor. 
    • Ensure LDRs are positioned correctly. 
  •  Servo Moves Erratically? 
    • Increase delay time for smoother movement.

Conclusion

The Sun Tracking System improves solar panel efficiency by automatically following sunlight using  LDRs and a servo motor. The system can be scaled up for larger solar farms and enhanced with dual-axis  tracking for better accuracy.


Comments

RFID-BASED ATTENDANCE SYSTEM