# Arduino 2-axis servo solar tracker

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 - 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)

Remove these ads by Signing Up

## 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.

jaykentchriss1 month ago

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 :)

robinmitchell1 year ago
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!!!
1 month ago

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 :)

McAldo1 year ago
That's a wonderful way to approach the problem, thanks for sharing it.
dpmdmph1 year ago
Did you have to calibrate ur continuous servos first, before putting them in ur project?
DaBlakus1 year ago
G'day,
How does it perform in low light levels, like say dusk or dawn ??
I have made up a 2 axis system which works well under "normal' sunshine but I'm having trouble when all sensors are returning similar levels ie. diffused light when cloudy.
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.
aplavins (author)  DaBlakus1 year ago
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.
robinmitchell1 year ago
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!!
I was successful at replicating your experiment!! thanks for sharing!!
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 :

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.

http://www.servocity.com/html/spg7950a-45_continuous_rotatio.html
Robin
Science Wizard1 year ago
Also in the diagram what is the two grey rounded pieces?
aplavins (author)  Science Wizard1 year ago
the tilt sensors
Science Wizard1 year ago
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?
aplavins (author)  Science Wizard1 year ago

1 year ago
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.
Science Wizard1 year ago
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!
aplavins (author)  Science Wizard1 year ago
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.
1 year ago
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?
aplavins (author)  Science Wizard1 year ago
I updated the diagrams on the instructable. They are both the same, just different views.
1 year ago
If I need to adjust the potentiometer in the servo meter, how would i do that?
Science Wizard1 year ago
Also, is the arduino code correct. Do i just copy and paste it. then upload it to the arduino board?
robinmitchell1 year ago
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?
aplavins (author)  robinmitchell1 year ago
Thanks for spotting that, it should be ground to ground.
maewert3 years ago

Cool project!  Great for an all-purpose tracker.  For a specific purpose (solar) tracker you may wish to consider using a polar mount instead of an alt-az mount.  This will mean that only one motor would move to track the sun throughout the day.  Since the position of the sun is predictable, you could compute its position and not rely on sensors. (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.)

Your solution could generate some electricity even from moonlight since it would track the brightest object and not necessarily only Mr. Sun however!  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!)  Actually I WOULD like to see that!  It would make me back up a few times!

Very nice instructable.  Best Wishes.
aplavins (author)  maewert3 years ago
Thanks for the comment, I agree that a "polar mount" 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.

An improvement I could make to this project would be to sense the ambient light and tell it not to track at night.
2 years ago
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.

Agree with the polar mount - you just need to change the elevation manually once a month for best angle.

GPS for configuration is overkill - a paper table of latitudes should be enough, and longitude doesn't affect it.

Also - this would make it a different project - I think the servo can be driven analog without needing an arduino.

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...
244 Jake3 years ago
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.

Reed switches could be used with magnets to define stop points.

Jake
Graver3 years ago
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?
Fun project.
aplavins (author)  Graver3 years ago
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.

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.

Hope this helps!
3 years ago
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
aplavins (author)  Graver3 years ago
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.

Increasing the value of sensitivity will reduce the amount of hunting.

nice pic, hope this helps!