Introduction: Arduino Solar Tracker (Single or Dual Axis)

Picture of Arduino Solar Tracker (Single or Dual Axis)

If you’ve installed solar panels on a camper van to provide you with electricity on your camping trip or at home to supplement your electricity usage or take your home completely off grid then you probably know that the panels work the best when they are aligned directly towards the sun. This sounds simple enough, except that the sun moves throughout the day. This is why there are now a number of different mechanisms which work on a range of principles with the purpose of aligning your panel or array of panels directly towards the sun, they are called solar trackers.

There are two principle types of trackers, single and duel axis trackers. Single axis trackers are adjusted every month or so account for seasonal changes in the suns position, the single axis is then used to track the daily movement of the sun across the sky. Duel axis trackers eliminate the need for monthly adjustment by using one axis to track the suns daily movement and another axis to track the seasonal movement. A single axis solar tracker improves solar output by around 25% and a dual axis tracker by around 40% according to this article on Altestore.

This solar tracker control system is designed to take light measurements from the east and west (left and right) side of the solar panel and determine which way to move the panel to point it directly at the source of the light. A servo is used to actuate the panel tracker; these are available in a broad range of sizes and can be scaled according to your panel size. Although this tracker is single axis, the two sensors and servo can simply be duplicated to provide dual axis control.

This project assumes you know the basics of Arduino programming, otherwise read my article on getting started with Arduino.

You could also take this project further by building your own solar panel as well, here is our guide on how to build a solar panel at home. If you are thinking of switching some or all of your homes power requirements to solar power, read my article on switching to solar power first.

Update: I have had a number of requests to show how this project and code can be modified to drive a linear actuator for heavier loads and panel arrays. I have written up a "how to" on the physical changes required as well as the revised software to make a linear actuator driven solar tracker.

Step 1: What You Will Need for a Solar Tracker

Here is a list of the items which you need in order to complete this project. If you are looking to make a dual axis tracking stand then you will need to double up on the servos, LDRs and resistors.

  • An Arduino (Uno used here) – Buy Here
  • Single Axis Tracking Stand (Brief DIY Design Shown In Step 6)
  • 2 x 4.7K Resistors – Buy Here
  • 2 x LDRs – Buy Here
  • PWM Servo – Buy Here

The specific servo model or size has not been stated as it depends on the size and weight of your solar panel. The one used in this project is a 9 gram analogue servo. You can use any size PWM hobby servo with the Arduino although the larger servos will require their own power source.

Step 2: Assemble the Components

Picture of Assemble the Components

First you need to start by assembling the components onto your solar panel, or breadboard. The LDRs (light dependent resistors) or PRs (photo-resistors) change resistance with changing light, therefore they need to be connected in such a way that the changing resistance is converted into a changing voltage signal which the Arduino understands. The servo is controlled through one of the Arduino's PWM outputs.

If you are going to be installing the solar tracker permanently then you may want to solder the resistors and LDRs together so that they cannot come loose. If you are simply trying this project for fun then a breadboard is perfect.

The basic circuit for the connection of the LDRs and servo to the Arduino is shown in the attached image.

The resistors R1 and R2 are each 4.7K, the PR1 and PR2 are the two LDRs and the servo can be any PWM hobby servo. If you are using a servo larger than 9 grams then the Arduino will probably not be able to supply it enough power to achieve its full torque capability, you will need to supply the servo directly with its own 5V power source.

If you are making this a permanent installation, then it is best to solder the resistors right up near the LDRs on the panel. This way you can run a single 4 core wire from the control box up to the sensors on the panel, the four cores will be 5V, Gnd and then signal 1 and 2 from the LDRs. Once your LDRs and resistors have been soldered together, you can mount them on your solar panel. Mount the LDRs on the east and west (left and right) sides of the panel facing towards the sun. Make sure that they are not shaded in any way by the frame and have an unobstructed view of the sun.

A breadboard has been used in this project purely to distribute the Ardunio's 5V power supply to both the resistors and the servo.

The servo needs to be sized according to the size of your solar panel. The panel used in this example is small and relatively light; a small servo was therefore used and is powered by the Arduino. For a larger servo (anything above 9 grams), you will need to power the servo externally as the Arduino doesn’t have sufficient capacity for it. Make sure that you connect the external power sources ground to the Arduinos GND as well otherwise the PWM control signal to the servo will not work.

Step 3: Upload the Sketch

Picture of Upload the Sketch

Now you can upload your sketch onto your Arduino, if you haven’t uploaded a sketch before then follow this guide on getting started.

The sketch is shown in the attached image.

Here is the link to download the Solar Tracker code.

The code essential measures the light intensity from both photo resistors, it then compares the two to see which is receiving more light. If the difference is greater than a small threshold then the Arduino tells the servo to move in that direction to direct the panel towards the light source. If the light falls below a certain level on both sensors then it is detected as night time and the panel is moved to face east again for sunrise.

Step 4: Autodesk Circuits Diagram & Simulator

Here is the setup drawn up in Autodesk Circuits, the code is also imbeded and can be simulated by dragging the light intensities on the LDRs once the simulation mode has been started.

Step 5: Calibrate the Sensor Error

Picture of Calibrate the Sensor Error

Because of differences between the LDRs, resistors and the resistance of the wire used, there will be a difference between the signal received from both sensors even when they are receiving the same amount of light. This is taken into account by introducing a calibration offset into the calculation, this number will need to be adjusted in your code according to your setup. Adjust this calibration factor where it is declared in the code,

Line 13: int calibration = 204.

The most accurate way to determine this factor is to shine a light equally between both sensors and then use the Serial monitor on your computer to read the values output by the east and west sensor. The difference between these two values will be the calibration offset. The LDRs are very sensitive so the tracker only moves when the difference between them is greater than 15 in the code otherwise it would be continuously tracking forwards and backwards and wasting power.

If you are not familiar with the Serial interface then you can play around with this value until the tracker remains still when a light is shined equally onto both sensors.

Step 6: Making a Single Axis Tracking Stand

While this instructable is centered more around the Arduino control and is not intended to detail making a tracking stand because of the extremely diverse range and size of panels available, here is a brief outline on the design along with some key pointers.

Your stand should look something like the attached image when it is complete.

Ideally the stand should be made from aluminium angle as it is strong, durable and suitable for outdoor use but it can also be made from wood, plywood or PVC piping.

The stand is essentially made in two parts, the base and the panel support. They are joined around a pivot point on which the panel support rotates. The servo is mounted onto the base and the arm actuates the panel support.

The panel should protrude from the panel support as little as possible to keep the out of balance load on the servos to a minimum. Ideally, the pivot point should be placed at the centre of gravity of the panel and panel support together so that the servo has an equal load placed on it no matter which direction the panel is facing although this is not always practically possible.

Two servos may be used for heavier panels, one on each side of the panel. The geometry needs to be the same and the servos need to be the same type/model. You can then duplicate the servo code in the software so that both servos are given the same reference position and move together to actuate the panel.

For very heavy panels or for solar arrays, the servos will need to be replaced with stronger stepper motors. The stepper motors will need to be driven by a driver board such as this one.

Please let me know if you have made this project or done something similar. I'm always looking for quicker and easier ways to do things. Leave a review in the comments section at this link to have some of your ideas added to our page.


nisha nish (author)2017-04-01

can u plzz give the circuit connections with servomotor ,and i want to see how tht servo was attachd to the stand

RobSanders123 (author)2017-02-13

Hi, I would like to build this project. Could you please tell me where you bought the servo pushrod? Also, could you give more details about the design of the tracking stand, i.e. what materials you used etc.


BrownDogGadgets (author)2016-11-29

Solar tracking is great, but honestly, you're better off spending extra money on an additional panel or two instead of dealing with it. Think about a bit, do you really want to worry about a moving mechanical system that sits outside 365 days a year? Something that could stop working if a single leaf falls over a sensor? Tracking for home use is rarely worth the extra time, money, and upkeep costs. Adding some extra panels will consistently give you the same results with 99% less work involved. We should know, we sell a small desktop dual axis solar tracking kit and get this question daily from people.

Hi BrownDogGadgets,

You are correct, if you have the space available then it is more reliable to install multiple panels rather than a solar tracker. On small scale its definitely not worth it but depending on the size of the array you are looking at tracking, it could be considerably cheaper to get the 20-40% extra form your existing panels.

Thanks for the input.

undinstructable (author)2016-11-29

Thank for sharing your project. Nice one. I dont know if you've heard about it but there is also a nice project (founded on Indiegogo) that instead of tracking for solar panels, it moves a mirror to direct sunlight straight into shaded areas of your home. And it has a cool design as well. Its called Lucy by Solenica, check it out here

Hi undinstructable,

Thank you. I've had a look at the project on Indigogo, it looks like a really innovative idea. I've never seen a project involving the control of reflected sunlight, quite interesting. Thank you for sharing.

tractorman1960 (author)2016-11-24

Very clearly written project; I will build one of these with my son. I have 7kw of roof top panels and this seems like a complicated thing to accomplish on a pitched roof. Plus I'm sure that in doing so I would void my system warranty- though I'd love to increase efficiency. Thanks!

Hello tractorman 1960, A solar tracker for a 7 kw would be much easy to implement with a slew ring drive. I plan to build one this summer with a 5 kw panel (20 panels of 250 w each, arranged in 10 panels on either side of the slew ring drive).

Thanks but mounting 20 panels to a slew ring drive on a pitched roof is not at "easy".

Hi tractorman1960,

Thanks so much. Yeah that could be a bit complicated. You could look at mounting each panel individually on its own tracker to follow the sun's movement. You would probably be able to control them all with one Arduino so the major cost will be in duplicating the tracking frame. Best to check if your warranty would still be valid though!

thediylife (author)2016-11-25

Hi All,

After numerous requests for an update on how to drive a linear actuator to move a heavier load or array of panels, I have written up a short guide on the required modifications and updated code:

Anirudh Ralhan (author)2016-11-24

Really Awesome and such a simple build!!!! with minimalistic parts too. Love it. Thanks for the awesome instructable :)

GalenW1 (author)2016-11-24

boesh (author)2016-11-24

Love this one, thnx !

Altoidian (author)2016-11-24

Very nice. Clean, few parts and efficient code. I really like that in a design.

I built a brushed motor solar tracker for solar photography some years ago that used basic code and a a basic stamp and dozens of parts, switches and complexity on top of complexity. It worked very precisely and never failed. But, what a doozy to calibrate since I was going for single millimeter precision. In the end, I dismantled it. Now, your simple design has given me cause to resurrect the idea since I see no reason your tracker can be as accurate. Thank you for an excellent Instructable.

thediylife (author)Altoidian2016-11-24

Hi Altoidian,

Thanks so much, I hope this project has inspired you to tackle yours again. I'm always looking for easier ways to do things, please let me know if you do try it out, I'd love to add a brushed or stepper motor option for heavier panels.

DIY Hacks and How Tos (author)2016-11-23

Very nice. Tracking drastically improves the efficiency of a panel.

Hi DIY Hacks and How Tos,

Thank you. Yes it really is worth while!

About This Instructable




Bio: The DIY Life is all about your next project. Be it a project to make improvements to your home, something fun to do or guiding ... More »
More by thediylife:DIY Designer MirrorOff Grid Van Power Information SystemSuper Easy 9V Emergency USB Charger
Add instructable to: