Introduction: Arduino Solar Tracking Robot


This is a simple solar tracker which automatically orients itself towards the sun or any bright source of light like the sun .If you place solar panels on this robot it can increase their productivity by 90 to 95 %. At first creating a solar tracking robot may sound complicated but it quite quickly becomes clear. As the title suggests it runs on the arduino board .This is a fun to do and low cost project.

This instructable was inspired from geo bruces instructable solar tracking robot

This instructable explains how to create your own solar tracking robot, how to set up the robot and how to test the robot.

This instructable is a entry in the robot challenge in the age category of 13 - 18 (I am 14 years old). 

Step 1: Parts & Tools

Parts:
~ 2 x Servo Motors - Local Electronics Store
~ 4 x LDR's - Local Electronics Store
~ 4 x 10k Resistors - Local Electronics Store
~ Arduino Uno - Sparkfun.com
~ 2 x 50k Variable Resistor - Local Electronics Store

Tools:
~ Soldering Iron - Sparkfun.com
~ Solder Wire  - Sparkfun.com
~ Jumper Wires - Sparkfun.com
~ Protoboard - Local Electronics Store

All the parts will cost you less than 30$ (Excluding the arduino and all the tools)

Step 2: Build the Circuit

The Circuit is pretty simple connect the four LDR's to analog pins 0,1,2 and 3 respectively via a 10k resistor.Connect the two servos to digital pins 9 and 10 respectively.Conect the two variable resistors to analog pins 4 and 5 .Take a Look at the pictures they really help.See the last picture for the circuit diagram (It might be the baddest that you have ever seen).

Step 3: Build the Sensor Assembly

To build the the sensor assembly take two rectangular pieces of cardboard, cut a long slit through the middle of the first cardboard piece.Cut a short slit through the middle of the second cardboard piece and then intersect both of them and fix them nicely using some tape. It should look like a 3D cross with 4 sections..We have to place our four LDR's in these four sections of the cross.See the pictures they really help.

Step 4: Set It Up

Find a base (Nescafe bottle in my case)  and stick your fist servo to it then to the rotor of the first servo connect the second servo.To the rotor of the second servo connect the sensor assembly that we made earlier.To test your robot take it out in the sun and it should automatically align itself towards the sun.If indoors it will align itself to the brightest source of light in the room. Take a look at the pictures they really help.

Step 5: The Code

Heres the code for your solar tracing robot:

#include <Servo.h> // include Servo library

Servo horizontal; // horizontal servo
int servoh = 90; // stand horizontal servo

Servo vertical; // vertical servo
int servov = 90; // stand vertical servo

// LDR pin connections
// name = analogpin;
int ldrlt = 0; //LDR top left
int ldrrt = 1; //LDR top rigt
int ldrld = 2; //LDR down left
int ldrrd = 3; //ldr down rigt

void setup()
{
  Serial.begin(9600);
// servo connections
// name.attacht(pin);
  horizontal.attach(9);
  vertical.attach(10);
}

void loop()
{
  int lt = analogRead(ldrlt); // top left
  int rt = analogRead(ldrrt); // top right
  int ld = analogRead(ldrld); // down left
  int rd = analogRead(ldrrd); // down rigt

  int dtime = analogRead(4)/20; // read potentiometers
int tol = analogRead(5)/4;

int avt = (lt + rt) / 2; // average value top
int avd = (ld + rd) / 2; // average value down
int avl = (lt + ld) / 2; // average value left
int avr = (rt + rd) / 2; // average value right

int dvert = avt - avd; // check the diffirence of up and down
int dhoriz = avl - avr;// check the diffirence og left and rigt

if (-1*tol > dvert || dvert > tol) // check if the diffirence is in the tolerance else change vertical angle
{
if (avt > avd)
{
servov = ++servov;
if (servov > 180)
{
servov = 180;
}
}
else if (avt < avd)
{
servov= --servov;
if (servov < 0)
{
servov = 0;
}
}
vertical.write(servov);
}

if (-1*tol > dhoriz || dhoriz > tol) // check if the diffirence is in the tolerance else change horizontal angle
{
if (avl > avr)
{
servoh = --servoh;
if (servoh < 0)
{
servoh = 0;
}
}
else if (avl < avr)
{
servoh = ++servoh;
if (servoh > 180)
{
servoh = 180;
}
}
else if (avl = avr)
{
// nothing
}
horizontal.write(servoh);
}
delay(dtime);
}

Step 6: All Done!

Hope this project inspires further experimentation. The Arduino board is incredibly versatile,cheap, and accessible to all hobbyists . This is just one of many simple projects which can be constructed using the arduino. Keep pondering!.Dont forget to follow morescomming up.For any queries contact me heres my E-mail ID r1398ohit@gmail.com

Comments

author
hesterbergnl (author)2012-09-28

Alright, so did you write this originally, or did this guy:

https://www.instructables.com/id/Arduino-Solar-Tracker/

author
geo bruce (author)hesterbergnl2013-05-01

the link you posted is mine instructable
I wrote it almost a year before this guy "copied" it.
but he didn't read the license terms

This license lets others remix, tweak, and build upon your work non-commercially, as long as they credit you and license their new creations under the identical terms.

"as long as they credit you" <<< you didn't :(

author

please Mr Geo can you help me i tried the project and the arm seems to run away
from light, and sometimes turning around light. Is it because of the
fact i used very small LDR? anyway i checked with the the serial monitor
the LDR are working. need your help please.

20160831_150646.3gp
author
Bot1398 (author)geo bruce2014-05-14

Hey, sorry for not mentioning it before. I have now mentioned your name and a link to the instructables

author
Tchakounte Hyacinthe (author)2016-08-31

please can you help me i tried the project and the arm seems to run away
from light, and sometimes turning around light. Is it because of the
fact i used very small LDR? anyway i checked with the the serial monitor
the LDR are working. need your help please.

20160831_150646.3gp
author
Tchakounte Hyacinthe (author)2016-06-20

Great work, thank for sharing. Please, How can i do to increase the sensibility of LDRs and the speed of servo?

author
lheise (author)2015-01-28

my servos just rotate 180° (it stays on 0° or 180°) they dont stay on 70° or 30° for instance.
anyone can help me?

author
aleza84 (author)2013-12-15

Are the separator between each photoresistor necesary?

author
Bot1398 (author)aleza842013-12-25

Yes

author
McAldo (author)2013-10-30

Nice tutorial, I like it and the cardboard solution is ingenious. Looking forward to try this :)

author
emdarcher (author)2012-09-06

you should make it powered by a solar panel that it holds, and directs towards the light, it would be independent. also you could split the power to go to the arduino, and some for surplus energy.

author
ftello barahona (author)2012-07-29

Your diagram has free wires

author
mmorlan62 (author)2012-06-14

That has got to be the punkiest build I've ever seen. LoL! :)

I like the simplicity of the circuit and code. Well done.

Consider painting your cruciform tube black (eliminating stray bounces off the cardboard) to improve the accuracy of the sensors.

Consider how this setup will react to cloudy days. Will it be sending the servos all over the place looking for the brightest spot in the sky? If so, how do you slow down the motion so you don't burn out the servos? Consider adding some acceleration curve code to the movement of the servos, especially once they are driving a load.

Also, consider adding a power relay circuit for the servos so your arduino can turn them on and off, thus relieving them of stress when they aren't moving anyway. The code could;

o turn on the relay, powering the servos
o move the servos to their new position via acceleration curves
o turn off the relay, shutting down the servos

Have fun!

author
seraine (author)2012-06-12

You should consider making a schematic, because it makes it a lot easier to understand. Great Instructable, though.

author
Bot1398 (author)seraine2012-06-12

I added a circuit diagram (last pic step 2) now

author
jwkooi (author)2012-06-12

Nice project! Well done. Do you have a youtube clip to see it working?

About This Instructable

43,022views

144favorites

License:

Bio: Preapering for my medical entrance exams
More by Bot1398:555 Crriter RepellentSolar Powered Clock HackDIY Astronomy Flashlight
Add instructable to: