Single Axis Solar Tracking System

Single Axis Solar Tracking System Using Arduino

Single Axis Solar Tracking System Using Arduino

This project creates an intelligent single-axis solar tracking system that automatically follows the sun's movement throughout the day. Using two LDR sensors and a servo motor, the system optimizes solar panel positioning to capture maximum sunlight, increasing energy efficiency by up to 40% compared to fixed panels.


How the System Works

  • Dual LDR Sensors continuously monitor light intensity on both sides of the solar panel
  • Arduino Nano processes LDR readings and calculates optimal panel position
  • Servo Motor adjusts panel angle (35° to 115° range) based on light differential
  • Smart Calibration with adjustable factors compensates for LDR variations
  • LED Indicators show tracking direction and system status
  • Ultra-Smooth Movement ensures precise and gradual panel adjustments
  • Fixed 45° Base Angle provides optimal year-round sun exposure
  • Integrated PCB Design ensures reliable and compact construction

Materials Required


PCB Design Files

Download the Gerber files for manufacturing your custom PCB:

Download Gerber Files

Order your PCBs from JLCPCB:

Order PCBs from JLCPCB

🎥 Watch the video above to see the solar tracking system in action and understand its assembly process!


Arduino Code

Upload this code to your Arduino Nano after completing all hardware connections:

#include 

// Define pins
#define LDR1 A0
#define LDR2 A1
#define LED1 2
#define LED2 3
#define servoPin 4

// Create servo object
Servo servo;

// Servo constraints
int Spoint = 90;
const int centerPos = 75;
const int leftLimit = 35;
const int rightLimit = 115;

// UPDATED LDR CALIBRATION FACTORS based on your readings
float ldr1Calibration = 0.91;  // Changed from 0.65 to 0.91
float ldr2Calibration = 1.0;   // Keep LDR2 as reference

int error = 85;  // Increased error margin to match your difference
int minLightThreshold = 150;

// Ultra-smooth movement settings
const int ultraSmoothStep = 1;
const int ultraSmoothDelay = 10;

void setup() {
  servo.attach(servoPin);
  servo.write(Spoint);
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  Serial.begin(9600);
  Serial.println("=== UPDATED CALIBRATION SOLAR TRACKER ===");
}

void loop() {
  int raw1 = analogRead(LDR1);
  int raw2 = analogRead(LDR2);
  int ldr1 = raw1 * ldr1Calibration;
  int ldr2 = raw2 * ldr2Calibration;
  int diff = ldr1 - ldr2;
  
  Serial.print("RAW1:");
  Serial.print(raw1);
  Serial.print(" RAW2:");
  Serial.print(raw2);
  Serial.print(" Servo:");
  Serial.print(Spoint);
  
  // Determine target position based on conditions
  int targetPos = Spoint; // Default: stay in current position
  
  if (raw1 < minLightThreshold && raw2 < minLightThreshold) {
    targetPos = centerPos;
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, LOW);
    Serial.println(" -> DARK");
  }
  else if (abs(diff) <= error) {
    targetPos = centerPos;
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, HIGH);
    Serial.println(" -> BALANCED");
  }
  else if (ldr1 > ldr2) {
    targetPos = max(leftLimit, Spoint - ultraSmoothStep);
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, LOW);
    Serial.println(" -> LEFT");
  }
  else if (ldr2 > ldr1) {
    targetPos = min(rightLimit, Spoint + ultraSmoothStep);
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, HIGH);
    Serial.println(" -> RIGHT");
  }
  
  // Apply ultra-smooth movement
  ultraSmoothMoveTo(targetPos);
  delay(30);
}

// Ultra-smooth movement function
void ultraSmoothMoveTo(int targetPos) {
  if (Spoint != targetPos) {
    // Calculate direction
    int stepDirection = (targetPos > Spoint) ? 1 : -1;
      
    // Move one step
    Spoint += stepDirection * ultraSmoothStep;
    
    // Constrain to limits
    Spoint = constrain(Spoint, leftLimit, rightLimit);
    
    // Move servo
    servo.write(Spoint);
    delay(ultraSmoothDelay);
  }
}

Code Explanation:

Setup Function:

Initializes servo motor, LED indicators, and serial communication. Sets initial servo position to 90° and prepares the system for light sensing operation.

Main Loop:

Continuously reads both LDR sensors, applies calibration factors, and calculates the light differential. Based on the difference, the system decides whether to move left, right, or stay centered. LED indicators provide visual feedback of the tracking direction.

Smart Features:

Includes calibration factors for LDR mismatch compensation, ultra-smooth movement to prevent jerky motion, and intelligent decision-making for optimal sun tracking.


Technical Specifications

Parameter Specification
Microcontroller Arduino Nano
Tracking Axis Single Axis (Horizontal)
Servo Range 35° to 115° (80° total movement)
Base Panel Angle Fixed at 45° for optimal exposure
Light Sensors 2x LDR with calibration factors
Movement Type Ultra-smooth incremental steps
Power Supply 7.4V Lithium Battery
Efficiency Gain Up to 40% vs fixed panels
Construction Custom PCB integrated design

Step-by-Step Assembly

1. PCB Manufacturing:

  • Download and order the Gerber files from JLCPCB
  • Wait for PCB delivery (typically 5-7 days)
  • Inspect PCB for any manufacturing defects

2. Component Soldering:

  • Solder Arduino Nano, headers, and terminal blocks first
  • Install resistors, capacitors, and LDR sensors
  • Connect servo motor connector and LED indicators
  • Ensure all solder joints are clean and secure

3. Mechanical Assembly:

  • Mount solar panel on servo motor horn
  • Set base angle to 45° for optimal sun exposure
  • Position LDR sensors on either side of the panel
  • Secure all components in weather-resistant enclosure

4. System Testing:

  • Upload Arduino code to Nano
  • Test LDR readings using serial monitor
  • Verify servo movement range and smoothness
  • Calibrate LDR factors for your specific environment
  • Test tracking functionality with light source

☀️ Maximum Efficiency

Increases energy capture by up to 40% compared to fixed solar panels

🔧 Easy Calibration

Adjustable LDR calibration factors for optimal performance in any environment

⚡ Smooth Operation

Ultra-smooth servo movement prevents jerky motion and reduces wear

💡 Smart Indicators

LED lights provide clear visual feedback of tracking direction and status


Performance Benefits

  • Increased Energy Output: 30-40% more power generation than fixed panels
  • All-Day Optimization: Continuous adjustment maintains optimal angle
  • Low Power Consumption: Efficient design minimizes tracking system energy use
  • Weather Resistant: Proper enclosure protects electronics from elements
  • Easy Maintenance: Modular design allows simple component replacement
  • Scalable Design: Can be adapted for larger solar panels

Advanced Customization Options

  • Add real-time clock for time-based positioning
  • Implement dual-axis tracking for even higher efficiency
  • Integrate weather sensors for storm protection
  • Add wireless monitoring and control
  • Implement battery level monitoring
  • Create mobile app for system status and control

Comments

Popular posts from this blog

Arduino Code Car Parking System

Arduino Code