loading
What is a solar tracker?

A solar tracker can increase the efficiency of a solar panel by up to 100%! It does this by always keeping the panel perpendicular to the incoming rays of sunlight.

here's an equation to prove this:

P = AW sin θ

P = power generated by the solar panel

A = Area of the solar panel

W = is the solar constant, which is equal to 1340 watts per square meter

θ = the angle of the incoming light

Since sin(90) = 1  you get the best performance out of the panel when it is totally perpendicular.

Materials:

1 - Arduino Uno w/ ability to program it
1 - Breadboard
1 - 2 axis tracking mechanism (i used a magnifying mirror that swiveled up and down)
2 - 360 deg continuous rotation servos
1 - ball bearing tilt switch or similar
5 - 10k resistors
1 - 5V breadboard power supply
3 - cadmium sulfide light sensitive resistors
wires
solder
soldering iron
vice (optional)

 

Step 1: The Y-axis

Depending on what you use as a tracking mechanism, yours might be a little different than mine.

I picked up a magnifying mirror from Shoppers normally used for shaving or applying makeup. It had a base and a swivel to tilt the mirror up and down.

I cut off one side of the swivel bracket and replaced it with a servo. I measured so that the shaft of the servo would line up with the swivel point of the mirror. I then had to drill a hole for the servo shaft to fit into.

I used hot glue and zip ties to secure the servo to the base and then the servo shaft inside the hole I had drilled.


Step 2: The X-axis

I marked the approximate center of the base and drilled a hole large enough to screw the setscrew for the servo armature in. I then hot glued the armature to the underside of the base making sure not to get glue in the hole i drilled.

Once the glue was dry, I attached the servo and screwed in the setscrew.

Step 3: The Sensors

I used 3 light sensors and 1 tilt sensor. You can substitute LEDs or photo-transistors for the CDS cells, and/or mercury switches for the ball bearing tilt sensor but your code will have to reflect the change(s).

I soldered wires from a scrap ribbon cable to the leads of each light sensor and a 2 pin header on the opposite end to connect easily to the breadboard. Use electrical tape / heat shrink / liquid insulator on the bare parts of the wire so that they don't short out.

Once that's done, hot glue the sensors at equal intervals around the circumference of the mirror. I placed the sensors so that the flat collecting side of the sensor was parallel with the plane of the mirror and angled out from the center just slightly.

The tilt sensor that I found was a plastic box with 4 contacts running through it and a ball bearing inside. This sensor prevents the tracker from pointing at the ground and also gives the y-axis an end-stop.

Solder wires onto the 4 pins of the tilt sensor then glue it on the back side of the mirror with the leads running horizontally. With the mirror pointing straight upward, the BB should be resting on the 2 middle leads.

The image I have uploaded is similar but not exactly the same as the tilt sensor I have. The one I used has only 4 leads.

Step 4: Wiring It Up

Take a look at the pics for the wiring diagram and schematic. (sorry about the confusing scheamtic, still learning Fritzing)

***EDIT (04/03/13)*** Changed the images to reflect the proper wiring and cleaned it up a bit.

Step 5: The Arduino Code

#define TILTL 2
#define TILTH 3
#define BOTTOM 2
#define TOPLEFT 0
#define TOPRIGHT 1
#include <Servo.h>
#include "math.h"

Servo hservo;
Servo vservo;
int tlsense;
int trsense;
int bsense;
int tavg;
int diff;
int spd;
int divisor;
int sensitivity;
int tiltl;
int tilth;

void setup () {
  vservo.attach(9); // attaches the servo on pin 9 to the servo object
  hservo.attach(10); // attaches the servo on pin 10 to the servo object
  divisor = 10; // this controls the speed of the servo. lower number = higher speed
  sensitivity = 5; // this controls the sensitivity of the tracker. lower number = higher sensitivity. if your tracker is constantly jittering back and forth increase the number
  Serial.begin(19200); // open serial com
  Serial.print("SolarTracker ready!");
  pinMode(BOTTOM, INPUT); // set the inputs
pinMode(TOPLEFT, INPUT);
pinMode(TOPRIGHT, INPUT);
pinMode(TILTL, INPUT);
pinMode(TILTH, INPUT);
}

void loop () {

tiltl = digitalRead(TILTL); // read the tilt sensor
tilth = digitalRead(TILTH);
tlsense = analogRead(TOPLEFT); // read the light sensors
trsense = analogRead(TOPRIGHT);
bsense = analogRead(BOTTOM);
//bsense = bsense * 1.05; // I had to adjust the value of this sensor to make it more accurate. you might have to do the same but start by leaving it alone
tavg = (tlsense + trsense)/2; // get an average value for the top 2 sensors
diff = abs(tavg - bsense); // this judges how far the tracker must turn
spd = diff/divisor; // and adjusts the speed of the reaction accordingly
spd = max(spd, 1); // sets the minimum speed to 1
Serial.print("\nTOP: "); Serial.print(tavg, DEC); // print the sensor values to the serial com
Serial.print("\tBOTTOM:"); Serial.print(bsense, DEC);
Serial.print("\tLEFT:"); Serial.print(tlsense, DEC);
Serial.print("\tRIGHT:"); Serial.print(trsense, DEC);

if((tavg < bsense) && (diff > sensitivity) && (tiltl == LOW) && (tilth == LOW)){ // if the average value of the top sensors is smaller (more light) than the bottom sensor and the tilt sensor is in the correct range
vservo.write(90 - spd); // send servo command to turn upward plus add speed
Serial.print("\tState: "); Serial.print("UP!");
}else if((tavg < bsense) && (diff > sensitivity) && (tiltl == HIGH) && (tilth == LOW)){ // if the average value of the top sensors is smaller (more light) than the bottom sensor and the tilt sensor is in the correct range
vservo.write(90 - spd); // send servo command to turn upward plus add speed
Serial.print("\tState: "); Serial.print("UP!");
}else if((tavg > bsense) && (diff > sensitivity) && (tiltl == HIGH) && (tilth == LOW)){ // if the value of the bottom sensor is smaller (more light) than the average value of the top sensors and the tilt sensor is in the correct range
vservo.write(90 + spd); // send servo command to turn downward plus add speed
Serial.print("\tState: "); Serial.print("DOWN!");
}else if((tavg > bsense) && (diff > sensitivity) && (tiltl == LOW) && (tilth == HIGH)){ // if the value of the bottom sensor is smaller (more light) than the average value of the top sensors and the tilt sensor is in the correct range
vservo.write(90 + spd); // send servo command to turn downward plus add speed
Serial.print("\tState: "); Serial.print("DOWN!");
}else{ // for every other instance
vservo.write(90); // stop the y-axis motor
Serial.print("\tState: "); Serial.print("STOP!");
}

tlsense = analogRead(TOPLEFT); // read the top 2 sensors again because they have probably changed
trsense = analogRead(TOPRIGHT);
//trsense = trsense * 1.03; // again I had to adjust the value of one sensor to make the tracker more accurate
diff = abs(tlsense - trsense); // reset the diff variable for the new values
spd = diff/divisor; // and generate a speed accordingly
spd = max(spd, 1); // set the minimum speed to 1

if((tlsense < trsense) && (diff > sensitivity)){ // if the top left sensor value is smaller (more light) than the top right sensor
hservo.write(90 + spd); // send servo command to turn left
Serial.print("\tState: "); Serial.print("LEFT!");
}else if((tlsense > trsense) && (diff > sensitivity)){ // if the top left sensor value is larger (less light) than the top right sensor
hservo.write(90 - spd); // send servo command to turn right
Serial.print("\tState: "); Serial.print("RIGHT!");
}else{ // for every other instance
hservo.write(90); // stop the x-axis motor
Serial.print("\tState: "); Serial.print("STOP!");
}


delay(10); // delay 10ms
}

Arduino polls the sensors and reacts accordingly making sure never to tilt too far down or up. The difference in light determines how fast the tracker should react.
 

Step 6: The Vid


Ya i look tired, I work a lot. Wanafightaboutit?
<p>good work</p>
<p>Hi I am making this tracker and using same of your code but the horizontal axis is not moving .. Can you please help me ?</p>
<p>Hello. Trying to understand the sketch and translate the comments, I'm sorry, correct me if I'm wrong, but maybe here is the error: <br>}else if((tavg &gt; bsense) &amp;&amp; (diff &gt; sensitivity) &amp;&amp; (tiltl == HIGH) &amp;&amp; (tilth == LOW)){ // if the value of the bottom sensor is smaller (more light) than the average value of the top sensors and the tilt sensor is in the correct range? <br>I think there should be <br>}else if((tavg &gt; bsense) &amp;&amp; (diff &gt; sensitivity) &amp;&amp; (tiltl == LOW) &amp;&amp; (tilth == LOW)){ // if the value of the bottom sensor is smaller (more light) than the average value of the top sensors and the tilt sensor is in the correct range</p>
<p>Dear Adam.</p><p>Two years ago I acquired a 10-Watt solar <br>panel, controller, battery. Two years this instrument <br>helps me in tourist trips. Naturally, the question arose about the tracker. I looked at many options on the Internet, and has collected this one: <br><a href="https://www.youtube.com/watch?v=Rt4HZOsOwNQ" rel="nofollow"> <br>https://www.youtube.com/watch?v=Rt4HZOsOwNQ </a> by purchasing servo motors (where <br>they at 60 degrees), but the functionality was not good.<br> <br>Since I <br>need two axis tracker, I stopped on Your wiring diagram, completely changing the mechanical part. I <br>purchased the Visduino UNO R3 and the breadboard <br>on Aliexpress. Previously on the market bought the photoresistors. I took the 10K resistors from a radio boards. Assembled circuit for half an hour. <br>Because with the Arduino I ran for <br>the first time and I don't know how to write sketches for the Arduino at all, I <br>just copied Your sketch, filled in the Arduino (detailed instructions how to <br>upload sketches to the <br>Arduino the Internet is full), hooked up to my 60-degree servos.It worked immediately.<br> <br>BUT!!!<br> <br>I have two <br>drivers UNL2003A and two stepper motors. So I would like to use <br>them in my scheme. <br><br> <br>Since I don't know how to write <br>sketches, can I ask You to help me in changing Your sketch, so instead of servo <br>motors to connect stepper motors and show the scheme <br>of connection on the Arduino? I would be <br>very grateful.</p><p>Translated by Yandex.</p>
Hello,<br><br>If you want to use stepper motors to control the tracker, I would recommend a STEP / DIRECTION style driver like this:<br><br>https://www.pololu.com/category/155/a4988-stepper-motor-driver-carriers-black-edition<br><br>There is some working code here:<br><br>http://www.cerebralmeltdown.com/2011/05/30/open-source-arduino-sun-trackingheliostat-program/#more-2866
<p>Thank you. But since I don't know enough English, I'm not able to program the Arduino, I want to know: can I connect two stepper motor whis drivers UNL2003A to the Arduino UNO R3; how to do it and to get changes in the sketch of Adam relative to the stepper motors. I do not in any way claim to the authorship of the sketch, when I'l publish the description, I will indicate the real authors of the sketch, but I need the actual version of the program. (although ideally have more requirements). If interested, I can throw on the mailbox.</p><p>Translated by Yandex.</p>
<p>y tilt sensors are used??/</p>
<p>dear admin</p><p>i want to know what is the role of tilt sensors?????</p>
<p>dear admin</p><p>i want to know what is the role of tilt sensors?????</p>
<p>Hi!... What about you will be adding a voltage and current sensors for the solar panel in your project?... it would be great if you will share to us your knowledge about coding. :)</p>
<p>good day!.. In your video, i see that there is no tilt sensor at the back of the mirror of your tracker... Where did you put your tilt sensor?... im just wondering... thanks... and also what if a mercury tilt sensor will be use?... how many mercury sensor will be used?... and can you send me the code please?.. i will really appreciate it.. Thanks :)</p>
i really wanted to thank you so much for sharing and posting this tutorial. it was my first experiment and programming experience and it was pretty easy after figuring out how to adapt a different type of tilt sensor. but because of your thorough commenting in your program sketch it was easy to modify your code. thank u thank u thank u!!!
<p>hi robinmitchell... did you used a mercury tilt sensor in your project?.. how many mercury tilt sensor did you used? i had difficulty in modifying the code when i used a mercury tilt sensor.. can u send the code? pls?... i will really appreciate it... thanks :)</p>
That's a wonderful way to approach the problem, thanks for sharing it.
Did you have to calibrate ur continuous servos first, before putting them in ur project?
G'day, <br>How does it perform in low light levels, like say dusk or dawn ?? <br>I have made up a 2 axis system which works well under &quot;normal' sunshine but I'm having trouble when all sensors are returning similar levels ie. diffused light when cloudy. <br>I have the sensors enclosed in short tubes 2 face 'forward' with the 3rd facing backwards to detect if the array is not facing the sun.
The code measures the ambient light and measures the difference between each of the sensors. Problems do arise when all the sensors are receiving the same amount of light. The best solution would be a hybrid of light tracking and positional tracking.
Hey Adam, nice update. interesting with this new set up, it looks like u can side step the alternate 5v power supply to the board. very cool!! <br>I was successful at replicating your experiment!! thanks for sharing!! <br>I was wondering about how to scale this project up to be able to carry a load of 40-50 lbs on top easily. ie a stirling engine and a fresnel lens : <br>https://www.youtube.com/watch?v=20wQOZbHXvo <br> <br>i found this servo set up that i think might be able to do the job but i thought i would ask u for your thoughts. if i can accomplish the same thing bu replacing it with this servo gearbox set up. <br> <br>http://www.servocity.com/html/spg7950a-45_continuous_rotatio.html <br>thanks in advance for your time, <br>Robin <br>thanks in advance for you <br>
Also in the diagram what is the two grey rounded pieces? <br>
the tilt sensors
Now both of my motors are working continually but the photocells aren't working. Also, the motors don't stop according to where the light is. How can i fix this? the 3rd wire, the pulse of the servo motor should have how many volts?
read this: http://www.princeton.edu/~mae412/TEXT/NTRAK2002/292-302.pdf <br> <br>google is your friend
i still don't know how to resolve my problem. What do I need to do so that the photo resistor or photocell tells the servo motors to move and stop according to the light detected.
Hi! I have made your solar tracker but with a different wooden mount but the wiring according to your diagram isn't working. The servo motors are either continuously turning or not at all. Can you email me or reply me here with further instruction on how to wire the arduino, breadboard, to the tracker to make it properly work. I would appreciate if you can get back to me by tomorrow. I need it for a special science fair project. Thank you! <br>
servo.write(90) should tell the servo to stand still. If it moves, you need to adjust the potentiometer inside the servo. there should be an access hole opposite the wires.
How would you do that and how do I connect the tilt sensor, I haven't done it so maybe that is a problem too? Also, can you send me a diagram with everything that i need to do and which diagram should i use from the two in your instructions? <br>
I updated the diagrams on the instructable. They are both the same, just different views.
If I need to adjust the potentiometer in the servo meter, how would i do that? <br>
Also, is the arduino code correct. Do i just copy and paste it. then upload it to the arduino board?
lovely project. i'm a newbie trying to recreate this project and i'm am curious why the ground connection on the pic is connected to the positive side of the servo motor on the breadboard image?
Thanks for spotting that, it should be ground to ground.
Adam,<br> <br> Cool project!&nbsp; Great for an all-purpose tracker.&nbsp; For a specific purpose (solar) tracker you may wish to consider using a polar mount instead of an alt-az mount.&nbsp; This will mean that only one motor would move to track the sun throughout the day.&nbsp; Since the position of the sun is predictable, you could compute its position and not rely on sensors.&nbsp;(This might mean that you might need to change to steppers instead of servos and power off the motors when they don't need to move maybe using a worm gear drive which holds its position after the motors are unpowered.)&nbsp;<br> <br> Your solution could generate some electricity even from moonlight since it would track the brightest object and not necessarily only Mr. Sun however!&nbsp; You might need an algorithm to determine if it is worth the electricity spent in the motors to eek out the most current (I'd hate to see a bank of solar cells track the headlights from a passing car at night!)&nbsp; Actually I WOULD like to see that!&nbsp; It would make me back up a few times!<br> <br> Very nice instructable.&nbsp; Best Wishes.
Thanks for the comment, I agree that a &quot;polar mount&quot; might be better for tracking the sun. I'm going to make one of those next. I want to be able to move it to different locations though. I'll probably need a gps sensor, compass, 3-axis accelerometer and an eeprom to store the sun's movement data.<br><br>An improvement I could make to this project would be to sense the ambient light and tell it not to track at night.
It would be best to return to the position needed for morning sun when you detect that night has fallen, while you still have some battery power available in case it is used up by some appliance overnight. <br> <br>Agree with the polar mount - you just need to change the elevation manually once a month for best angle. <br> <br>GPS for configuration is overkill - a paper table of latitudes should be enough, and longitude doesn't affect it. <br> <br>Also - this would make it a different project - I think the servo can be driven analog without needing an arduino. <br> <br>Good to see people working on this prohlem, there are no cost-effective trackers that I know of for the size of panel you'd buy for an RV or a boat - just toy ones for tiny panels and industrial ones for kilowatt panels...
Well a solar tracker, yes, but if you wanted to use what I see, a small mirror, and focus its light on water tank, all day long. That would most kool. A group of small mirrors could be grouped to all reflect the Suns heat to tank, all day long. <br> <br>Reed switches could be used with magnets to define stop points. <br> <br>Jake <br>
Hi, I have put together your sun tracker. I could not find a ball bearing tilt switch so I substuted mercury switches not having luck with them as limit switches. I munted one up and one down at the axes line may be they should be out from closed to center. They don't stop the Y axes from rolling. I don't undersand how you arrived at the values for bsense = 1.05 and trsense = 1.03. What values should I see in ambient light and in direct sun light? What do you think about using 180 degree servos instead of continuous servos? <br>Fun project.
I tested the 3 sensors from a single light source after they were mounted. the bottom sensor and top right sensor were giving me values that were lower than the top left sensor. This is probably due to some small variation in its manufacturing. The values 1.03 and 1.05 are ratios that the read analog value are multiplied by. I arrived at these values by powering up the tracker indoors where it would track the light on the ceiling. I used trial and error on the values until the mirror pointed the reflection of the light straight back at it.<br><br>Using 180 degree servos would be totally possible but would require major modification to the code. 360 degree servos use no feedback system and the pulse value you send to it represents a speed. With 180 degree servos, the pulse value represents a position.<br><br>Hope this helps!
Hi Apiavins: Still have a problem with the 1.03 and 1.05 numbers. Tried changing the 1.03 and 1.05 numbers to calabrate the sensors but they didn't seem to change. Did notice that bsense = bsense * 1.05 and trsense = trsende * 1.03 were commented out. I guess I don't understand were the calabration takes place. I have noticed that the sensor platforn does hunt a lot once it faces the light source. Think you said that sensitivity will take care of that. I will send you a photo of my tracker
by default, the program doesn't change the values of bsense and trsense. you will have to uncomment the lines that multiply those values. you can also add a line to modify tlsense if you think that's more appropriate.<br><br>Increasing the value of sensitivity will reduce the amount of hunting.<br><br>nice pic, hope this helps!

About This Instructable

84,234views

98favorites

License:

More by aplavins:Arduino 2-axis servo solar tracker 
Add instructable to: