Project showcase
Solar Tracker 35W with DC Motors

Solar Tracker 35W with DC Motors © GPL3+

Solar tracking photovoltaic (dual axis) that follows the sun, using LDR sensors and two DC motors.

  • 8 views
  • 0 comments
  • 0 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
09670 01
SparkFun Dual H-Bridge motor drivers L298
It's used to control the two motors
×1
07wx4951 40
LDR, 1 Mohm
×4
Mfr 25frf52 10k sml
Resistor 10k ohm
×6
Mfr 25frf52 1k sml
Resistor 1k ohm
×4
30b5650 40
Industrial Pushbutton Switch, Push-Pull
×4
E switch eg1218 image 75px
Slide Switch
×2
28c5043 40
Geared DC Motor, 12 V
×2
12070 01
SparkFun Solder-able Breadboard
×2
Photovoltaic 35W
×1
LM2596
This component is used to regulate the voltage. Because voltage from pv can exceed 12V, LM2598 gives output voltage 12V.
×1

Necessary tools and machines

09507 01
Soldering iron (generic)
4966285
Solder Wire, Lead Free

Apps and online services

About this project

This project is designed for educational purposes. It will be used for demonstration to students in order to have a first touch with solar trackers and photovoltaics.

The project is related to renewable energy and specifically photovoltaics. A dual axis solar tracker with photovoltaic was designed in order to follow the sun during the day. Photovoltaic powers the solar tracker (no external source needed).

To track the sun, I used four LDC sensors and Arduino compares the data from them to rotate the panel in the direction with the most sunlight using two DC motors (one for each axis) and motor driver.

There is a remote control with an auto/manual switch, single axis/dual axis switch and four buttons. While the first switch is turned to manual, you can manually rotate the panel using the four buttons (clockwise-anticlockwise in horizontal and vertical axis). While this switch is turned to manual, we have auto tracking of the system, single or dual depending the second switch.

Code

Solar Tracker Arduino
Arduino Code. NOTE: The names of the ldrs in the code do not correspond with their place in the breadboard!
/* Solar Tracker Code with 4 buttons for manual orientation and
  4 ldr sensors to automaticaly traking the sun.

*/
//set constant pin numbers
int wbuttonPin = 4;
int ebuttonPin = 2;
int tbuttonPin = 8;
int bbuttonPin = 12;
int switch1Pin = 7;
int switch2Pin = 5;
int eldr = A0;
int wldr = A1;
int tldr = A2;
int bldr = A3;
int IN1 = 13;
int IN2 = 9;
int IN3 = 10;
int IN4 = 11;
int eastldr = 0;
int westldr = 0;
int topldr = 0;
int botldr = 0;
int error = 0;
int poserror = 0;
int tberror = 0;
int tbposerror = 0;
int westbutton = 0;
int eastbutton = 0;
int topbutton = 0;
int botbutton = 0;
int onoffswitch = 0;
int singledualswitch = 0;
void setup() {
  pinMode (A0, INPUT);
  pinMode (A1, INPUT);
  pinMode (A3, INPUT);
  pinMode (A4, INPUT);
  pinMode (8, INPUT_PULLUP);
  pinMode (12, INPUT_PULLUP);
  pinMode (13, OUTPUT);
  pinMode (9, OUTPUT);
  pinMode (10, OUTPUT);
  pinMode (11, OUTPUT);
  pinMode (4, INPUT_PULLUP);
  pinMode (2, INPUT_PULLUP);
  pinMode (5, INPUT_PULLUP);
  pinMode (7, INPUT_PULLUP);
  Serial.begin(9600);
}

void loop() {Serial.print("start programm");
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
  onoffswitch = digitalRead(switch1Pin);
  singledualswitch = digitalRead(switch2Pin);
  while  (onoffswitch == LOW  ) {
    //manual rotating of the panel

    eastldr = analogRead(A0);
          westldr = analogRead(A1);
          topldr = analogRead(A2);
         botldr = analogRead(A3);
    
    eastbutton = digitalRead(ebuttonPin);
                 if (eastbutton == HIGH)
  { digitalWrite(IN1, HIGH);
    digitalWrite(IN2, LOW);
    } // rotate to east side when you push the right button
    else {
      digitalWrite(IN1, LOW);
    }
    westbutton = digitalRead(wbuttonPin);
                 if (westbutton == HIGH)
  { digitalWrite(IN2, HIGH);
    } //rotate to west side when you push the left button
    else {
      digitalWrite(IN2, LOW);
    }
    topbutton = digitalRead(tbuttonPin);
                if (topbutton == HIGH)
  { digitalWrite(IN4, HIGH);
    } //rotate to west side when you push the left button
    else {
      digitalWrite(IN4, LOW);
    }
    
    botbutton = digitalRead(bbuttonPin);
              if (botbutton == HIGH)
{ digitalWrite(IN3, HIGH);
  } //rotate to west side when you push the left button
  else {
    digitalWrite(IN3, LOW);
  } onoffswitch = digitalRead(switch1Pin);
    singledualswitch = digitalRead(switch2Pin);
    Serial.println(eastldr);
Serial.println(westldr);
Serial.println(topldr);
Serial.println(botldr);
}
   
//automaticaly rotating of the panel
//check east-west orientation first


                                      /* if (eastldr < 400 && westldr < 400)
                                         {digitalWrite(IN1,HIGH)
                                         delay(7500)
                                         digitalWrite(IN1,LOW)}*/
onoffswitch = digitalRead(switch1Pin);
singledualswitch = digitalRead(switch2Pin);
while  (onoffswitch == HIGH && singledualswitch == LOW ){
  eastldr = analogRead(A0);
          westldr = analogRead(A1);
          topldr = analogRead(A2);
         botldr = analogRead(A3);
                    error = (((eastldr+topldr)/2) - ((westldr+botldr)/2));
                            poserror = abs(error);
                                     if (poserror > 10){
 if (error > 0) {
   digitalWrite(IN2, HIGH);

//  Serial.print("IN2 HIGH");
  }
  else if (error < 0)    {
   digitalWrite(IN1, HIGH);
//Serial.print("IN1 HIGH");
  }}
  else if (poserror <= 10 )  {
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, LOW);
//Serial.print("LOW BOTH");
    }

Serial.println(eastldr);
Serial.println(westldr);
Serial.println(topldr);
Serial.println(botldr);

onoffswitch = digitalRead(switch1Pin);
singledualswitch = digitalRead(switch2Pin);}

onoffswitch = digitalRead(switch1Pin);
singledualswitch = digitalRead(switch2Pin);



  while  (onoffswitch == HIGH & singledualswitch == HIGH ){
         topldr = analogRead(A2);
         botldr = analogRead(A3);
         eastldr = analogRead(A0);
         westldr = analogRead(A1);
                 
                  
                  tberror = (((topldr+westldr)/2) - ((botldr+eastldr)/2));
                            tbposerror = abs(tberror);
    
 
                   error = (((eastldr+topldr)/2) - ((westldr+botldr)/2));
                            poserror = abs(error);
                                     if (poserror > 10){
 if (error > 0) {
   digitalWrite(IN2, HIGH);

//  Serial.print("IN2 HIGH");
  }
  else if (error < 0)    {
   digitalWrite(IN1, HIGH);

//Serial.print("IN1 HIGH");
  }}
  else if (poserror <= 10 )  {
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, LOW);
    }

Serial.println(eastldr);
Serial.println(westldr);
   if (tbposerror > 10)
{ if (tberror > 0) {
    digitalWrite(IN4, HIGH);

}    else if (tberror < 0)    {
      digitalWrite(IN3, HIGH);

    }
  }
  else if (poserror <= 10 )  {
    digitalWrite(IN4, LOW);
    digitalWrite(IN3, LOW);
  }
  onoffswitch = digitalRead(switch1Pin);
singledualswitch = digitalRead(switch2Pin);}
onoffswitch = digitalRead(switch1Pin);
singledualswitch = digitalRead(switch2Pin);
  delay(200);

}

Schematics

Circuit
You can use 1 breadboard instead of two. I just put second breadboard for the 4 LDRs above the Photovoltaic which is far from the first breadboard.

Download this schematic for more clear vision of Arduino pins
circuit_LruRyLeSCP.fzz
Circuit
LM2596 and L298 shown in the picture

Download the other schematic for more clear vision of Arduino pins
Circuit new z3ejqojcsp

Comments

Similar projects you might like

Dual Axis Solar Tracker Panel with Auto and Manual Mode

Project tutorial by Giannis Arvanitakis

  • 14,967 views
  • 10 comments
  • 61 respects

Solar Tracker with Live Data Feed - Windows IoT

Project tutorial by Jed Hodson

  • 12,667 views
  • 1 comment
  • 25 respects

Solar Tracker V2.0

Project tutorial by Brown Dog Gadgets

  • 14,303 views
  • 3 comments
  • 77 respects

Integrated Solar ChargeController, Inverter, PowerBank, Lamp

Project tutorial by Shahariar

  • 11,056 views
  • 26 comments
  • 41 respects

Tricks for Controlling DC Motors

Project tutorial by tolgadurudogan

  • 25,321 views
  • 6 comments
  • 83 respects

DC Motors Controller Board

Project showcase by Shahariar

  • 2,557 views
  • 0 comments
  • 8 respects
Add projectSign up / Login