Project tutorial
Solar Panel Sun Tracker - Phone Charger

Solar Panel Sun Tracker - Phone Charger © GPL3+

Fun and easy green robot! Build a sun tracking solar array in under an hour. Bonus: charge your phone with free clean energy!

  • 32,371 views
  • 14 comments
  • 142 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
Servos (Tower Pro MG996R)
9gram servo that doesn't need external power
×1
Adafruit industries ada161 image 75px
Photo resistor
×2
Mfr 25frf52 10k sml
Resistor 10k ohm
×2
2.5V to 5V boost converter - USB Adapated
×1
Solar Panel - Hobby Size
Any small panel will do, the higher the output the better, but keep it small and light
×2

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

Going Green

I have been working in the renewable energy industry in Australia and tinkering with Arduinos for some time now, but its not until this project that I finally decided to combine the two and build my own small solar device. One small note up front, this project obviously requires 5V to power the Arduino and servo, which are used to maximise the output of solar panels that at best at produce 3.4V. So its not exactly paying itself off. However the concept is scalable, so if, for example, you used this concept on an array of 8 panels, producing 12V, well then you could power the arduino and charge your phone without an external power source. I plan to do this one day, and will add a link here when it happens.

While I'm here, I better give credit to my sources...

The DIY Life - http://www.the-diy-life.com/arduino-solar-tracker/

Brown Dog gadgets - http://www.instructables.com/id/Solar-Altoids-USB-Charger/

Both are good sources of info on the subject, and where I got the concept from.

GETTING STARTED

So, first things first, you need some solar panels. I used two, although you can use however many you want, just think about how much a 9gram servo is going to be able to lift/lower (dont make it too heavy). The panels I found were rated at 1.5V, 0.75W output which is on the lower end available these days. But they were light and cheap and given this is a proof of concept project for me, the output isn't super important.

I joined my two panels along the edge with epoxy. To connect the panels into a string, just solder the positive lead of one panel to the negative lead of the other, which should leave you with a positive and negative wire left over. Attach your two LDR's to each side of the solar panel (East and West), and solder one end of a jumper wire to each of their leads. Its easier to solder a jumper wire if you cut the end off one side, and strip the lead about 5mm to expose the wires.

For the Arduino to read the LDR's, we need a voltage divider circuit for each. See here for voltage dividers. In this circuit, the LDR is R1, and we use a 10kohm resistor for R2, and join jumper wires to the arduino where the two resistors meet. If your building this project on a breadboard, one LDR lead will go to the voltage divider, the other goes to the positive power rail. See Fritzing diagram below.

The Tracker Structure

The next thing you need to build is a swivel support structure for the panel to sit on. My design is basically a length of spring steel supported by two A frames. The underside of the panel array has small wooden struts, with holes for the spring steel. I made the whole thing out of balsa wood to keep it cheap, easy and light, but if this was to be a permanent fixture you would want it out of thin steel or treated ply wood. I didnt document the building of the swivel support very well, but the video below should show you how its done, as well as the location of the servo.I built mine with the panel on a downward angle, so as to be able to face the base of structure north, so whichever way the panel swings as it tracks the sun, it will always be tilted a little bit north to maximise the output. (Im in the southern hemisphere)

Mounting the Servo

The Servo sits on one of the support beams of the A frame structure, and lifts/lowers one side of the panel. I folded some spring steel with pliers to get hooked ends you can loop it through your panel strut and servo arm, you may have to widen the holes in the servo arm to fit the steel, I used the smallest drill bit I could find. Dont glue the steel into either the servo arm or panel strut, as it must be able to rotate within the holes for the panel to lift smoothly. Once its in place, take the panel off the structure, so that only the servo remains so you can do some calibration.

Calibrating the Servo

Open a new sketch and input the following code.

#include <Servo.h>
Servo myservo1;   // Create a servo object to control the servo
int pos = 10;
void setup() {
 myservo1.attach(9);   //attaches the servo object to PWM pin 9
}
void loop() {
 myservo1.write(pos);}

Upload to your arduino, and see where the servo moves to. Keep changing the 'pos' value between 0 and 180 in the sketch and re uploading the sketch, until you find the positions where the servo arm points straight up and down. Those are your max and min values. For me, it was 15 and 140. If the value somehow overlaps from 180-back to 0, take the servo arm off and reposition it so that it can be aligned correctly.

Putting in together

Go ahead and connect everything up, and input the following sketch.

//Sun Tracker Sketch 
//
//This sketch is designed for use with a 9gram servo, able
//to be powered directly from the Arduinio without an external 
//power source. For fritzing diagram, see Github repository 
//https://github.com/nickalanf/Arduino--Projects
//The Serial monitor section is for debugging purposes, or for general interest,
//one once the device is functioning correctly, can be diasabled
//
//Sketch by FIELDING - 8/2/18
#include <Servo.h>
Servo servo;   // Create a servo object to control the servo
int eLDRPin = A0; // Assign pins to the LDR's
int wLDRPin = A1;
int eastLDR = 0; //Create variables to store to LDR readings
int westLDR = 0;
int difference = 0; //Create a variable to compare the two LDR's
int error = 10;  // Variable for is there is a noticable difference between the tow LDR's
int servoSet = 130; //Variable for position of servo - will be different for each device
void setup() {
 servo.attach(9);   //attaches the servo object to PWM pin 9
 Serial.begin(9600); 
}
void loop() {
 eastLDR = analogRead(eLDRPin); //Read the LDR values
 westLDR = analogRead(wLDRPin);
 if (eastLDR < 400 && westLDR < 400) {  //Check to see if there is low light on both LDR's
   while (servoSet <=140 && >=15) {     // if so, send panels back to east for the sunrise
     servoSet ++;
     servo.write(servoSet);
     delay(100);
   }
 }
 difference = eastLDR - westLDR ; //Check the difference 
 if (difference > 10) {          //Send the panel towards the LDR with a higher reading
   if (servoSet <= 140) {
     servoSet ++;
     servo.write(servoSet);
   }
 } else if (difference < -10) {
   if (servoSet >= 15) {
     servoSet --;
     servo.write(servoSet);
   }
 }
 Serial.print(eastLDR);      //Serial monitor can be useful for debugging/setting up
 Serial.print("   -   ");    //Use it to see if your LDR's are noticeably different when
 Serial.print(westLDR);      //They have equal light shining on them, if so, correct with the error value
 Serial.print("   -   ");
 Serial.print(difference);   
 Serial.print("   -   ");
 Serial.print(servoSet);     //Fine tune the servo settings, to maximise swing available
 Serial.print("   -   ");
 Serial.println(".");
 delay(100);}

Open the Serial Monitor, and shine light onto the LDR's. Try and shine it evenly on to both, and check the difference value being printed to the serial monitor is. If its anything greater than about 25, or less than -25, you need to add an error calibration. Add the relevant error value into the code, and then add or subtract that value from the relevant LDR. If the difference values are close, it should be fine to leave as is.

Your ready to give it a test! the easiest is to go into a dark room and with a torch/lamp. swing the light from one LDR slowly to the other and watch the panel move. You can also cover up one LDR and the panel should swing away from that one.

BONUS- PHONE CHARGER

If you want to actually make use of the panels output, you can wire up a 2.5V- 5 V DC-DC boost converter directly to the leads coming off the panels. Its an entirely separate circuit from the arduino/breadboard. Note than a standard phone charges at 5V, and your panels may be putting out 5 V but a low current, so if your battery is full or the sunlight low, you wont have enough output to charge. The easiest way around this is to simply add more panels!

Code

Sun TrackerProcessing
//Sun Tracker Sketch 
//
//This sketch is designed for use with a 9gram servo, able
//to be powered directly from the Arduinio without an external 
//power source. For fritzing diagram, see Github repository 
//https://github.com/nickalanf/Arduino--Projects

//The Serial monitor section is for debugging purposes, or for general interest,
//one once the device is functioning correctly, can be diasabled
//
//Sketch by FIELDING - 8/2/18


#include <Servo.h>

Servo servo;   // Create a servo object to control the servo
int eLDRPin = A0; // Assign pins to the LDR's
int wLDRPin = A1;
int eastLDR = 0; //Create variables to store to LDR readings
int westLDR = 0;
int difference = 0; //Create a variable to compare the two LDR's
int error = 10;  // Variable for is there is a noticable difference between the tow LDR's
int servoSet = 130; //Variable for position of servo - will be different for each device


void setup() {
  servo.attach(9);   //attaches the servo object to PWM pin 9
  Serial.begin(9600); 
}

void loop() {
  eastLDR = analogRead(eLDRPin); //Read the LDR values
  westLDR = analogRead(wLDRPin);

  if (eastLDR < 400 && westLDR < 400) {  //Check to see if there is low light on both LDR's
    while (servoSet <=140 && >=15) {     // if so, send panels back to east for the sunrise
      servoSet ++;
      servo.write(servoSet);
      delay(100);
    }
  }

  difference = eastLDR - westLDR ; //Check the difference 
  if (difference > 10) {          //Send the panel towards the LDR with a higher reading
    if (servoSet <= 140) {
      servoSet ++;
      servo.write(servoSet);
    }
  } else if (difference < -10) {
    if (servoSet >= 15) {
      servoSet --;
      servo.write(servoSet);
    }
  }
  Serial.print(eastLDR);      //Serial monitor can be useful for debugging/setting up
  Serial.print("   -   ");    //Use it to see if your LDR's are noticeably different when
  Serial.print(westLDR);      //They have equal light shining on them, if so, correct with the error value
  Serial.print("   -   ");
  Serial.print(difference);   
  Serial.print("   -   ");
  Serial.print(servoSet);     //Fine tune the servo settings, to maximise swing available
  Serial.print("   -   ");
  Serial.println(".");
  delay(100);
}

Schematics

suntracker_bb_4YYw7HZDM9.png
Suntracker bb 4yyw7hzdm9

Comments

Similar projects you might like

Dual Axis Solar Tracker Panel with Auto and Manual Mode

Project tutorial by Giannis Arvanitakis

  • 7,141 views
  • 6 comments
  • 37 respects

Servo-Controlled, Light-Tracking Solar Panel Platform

Project tutorial by scott mangiacotti

  • 12,449 views
  • 10 comments
  • 41 respects

Solar Charged Battery Powered Arduino Uno

Project in progress by Igor Fonseca Albuquerque

  • 60,674 views
  • 46 comments
  • 124 respects

Arduino Sun Tracker Turret

Project tutorial by Team RobotGeek Projects Team

  • 32,141 views
  • 1 comment
  • 151 respects

Integrated Solar ChargeController, Inverter, PowerBank, Lamp

Project tutorial by Shahariar

  • 7,733 views
  • 16 comments
  • 30 respects

Herb Box Eco System

Project tutorial by Walter Heger

  • 37,028 views
  • 20 comments
  • 239 respects
Add projectSign up / Login