DIY 5.2kW Solar Tracker Controlled by Raspberry Pi





Introduction: DIY 5.2kW Solar Tracker Controlled by Raspberry Pi

A solar tracking system can increase the output of the solar farm with up to 40%. All commercial solar tracking systems I have found cost more than 40% of the total cost based on a fixed installation. Some solar tracking systems cost 2 times more than a fixed installation.

Hence it is better to buy more panels than to invest in solar tracking, unless you build the solar tracking system yourself. I set out to design and build a 5.2 kW solar tracking array, consisting of 20 panels, 260W each.

Each panel is about 1x1,6 meters, so the construction consist of 2 rows of panels, each row is about 2 meters high and 12 meters long.

The electronics I use to control the dual axis motion needs to be low cost, yet reliable. I decided to use a Raspberry Pi computer to calculate the sun position and to control the motors. The program was developed using Python, it is so easy to learn that anyone can understand and modify the program.

I spent about 6000 Euro/Dollars on solar panels, 3-phase inverter and cables.

The solar tracking system cost about 3 000 Euro. A fixed frame would cost about 1000 Euro.

I did not count my hours, but it was several days of work to build this.

The most expensive parts of the solar tracker was the linear motors, I used 4 motors (120 Euro each) and 4 drivers (50 Euro each)

Step 1: (Optional Step) Build Prototype

The prototype was built from scrap wood. It is actually two frames, one larger frame to track the suns vertical position, and one smaller frame to follow the horizontal position. The solar panel is mounted on the smaller frame.

Galvanized waterpipes are used to mount the frames and allow for the rotating movement.

An old screw driver was used as a linear motor, the Raspberry PI controls a motor driver that can set the speed and direction of the screw driver. The prototype only tracked one axis.

Materials used for prototype

  • Old 12V screw driver used as motor
  • RaspberryPi computer to calculate sun position and move the frame
  • Parallax HB-25 motor driver to drive the motor with GPIO pins
  • Limit switch to detect Home position
  • 10mm threaded rod and nuts used for linear motion
  • 12V DC source
  • 12V to 5V converter for the Raspberry Pi to run on 12 V

All plastic parts for the prototype was made in my 3D printer.

I have attached the Python code for my prototype to this step in the instructable.

Step 2: Build the Full Scale Solar Tracker

The solar tracker frame was built mainly with impregnated 2" by 4".

A stable foundation is very important. Depending on the ground conditions, you might want to dig or make concrete foundations. I used a mix of both since I found bedrock on some locations while digging.

I will continue to write on this instructable when I have a moment to spare.

I have the code, the bill of materials, drawings, lots of photos.... Let me know if you have questions.

The system has been online since august 2016. The production is displayed here:

Step 3: ​Configure the Raspberry Pi

Follow these steps to configure your Raspberry Pi

  • Install Raspiban for Raspebrry Pi
  • Download and install bitwise SSH on your PC (To remote control the Pi)
  • Set time and date
  • Set time zone
  • Enable NTP so the time is always correct
  • Enable wireless
  • Disable ipv6
  • Install Python 3.5
  • Install Pysolar (Calculates the position of the sun based on the date and time)
  • Install RPI.GPIO
  • Create a program to control the solar tracker, or let me know if you want mine.

I use an apache2 web server and run parts of my application as a Python CGI in order to remote control the applicaiton. This way any device with a web browser can be used to control the application.

The plastic parts in the picture was made in my 3D printer.

Step 4: Let Me Know If You Need Any Further Information

More pictures and a video will be added soon.



    • Paper Contest 2018

      Paper Contest 2018
    • Science of Cooking

      Science of Cooking
    • Pro Tips Challenge

      Pro Tips Challenge

    We have a be nice policy.
    Please be positive and constructive.




    Great project Mats! Can you provide some more detailed plans or pictures for the construction? Maybe parts numbers for the linear actuators? I am building my own solar setup, and yours seems to be very wind resistant, which is what I need. Any more detail/plans would be appreciated! Hello from Tennessee, USA.

    Hello! The linear actuators are: 30" Stroke 400lb Force Linear Actuators. Product Code RB-FRA-89. I bought them from

    I use 4 in total since I got two rows of panels. Each row need one actuator for tilting and one for turning the panels.

    The raspberry pi is connected to the Parallax HB 25 DC Motor controller, the motor controller powers the linear actuators. I saw a while back that Parallax has released a better motor controller since I bought this.


    Hello Mats
    It is a fine project you've made, I find it safe in stormy weather.
    Your panels are pretty close to each other, don't they shade each other in the morning.
    What time of day is they free of shade from each other.



    Hi Martin. There is some shading in the morning and in the evening. The sun does not provide very much energy during that time so there is no great loss. I position the panels so they do not shade each other. This means they are not facing the sun directly, but there is so little energy there is no loss. The times depends on the angle of your array and the time of year.

    Hi Martin. I don't know how storm proof it is yet. I had some wind during the winter and it seems good. The concrete Foundation is 1 meter deep so it should be good. Denmark can be a lot windier so you might need more struts.

    The second row is about about 50cm higher that the front row of panels, it is a bit shade in the morning and evening but not much. Today the production of this sun tracking solar array was more than 50% more efficient than my fixed solar array. I have one 5,2kW fixed solar panel array and this one.

    There is a bit of shade at sunrise and sundown, but the power produced during the morning and evening is very low.

    I got 10kWh from the sun tracking 5,2kW array today and only 6kWh from the fixed 5,2kW array.

    I built this in august, so I'm not sure how much I will loose from shadow in the summer. It seems like the atmosphere takes most of the sun during the shady hours.

    I need to see how it behaves in the summer before I can know for sure....

    Hi Mats. I'm interested in your project. I'm about to build a trough solar concentrator, and I need a way to very precisely point it at the sun.

    Some questions for you:

    1) You answered one commenters indicating that you that you've "attached" various code. Do you mean, the code would be accessible via the Download button? I'm wondering, since it seems that the download button only works if you have a premium Instructables account. I'd love to see the whole bit.

    2) Is the motor always spinning, or does it move periodically then stop.

    3) Does the Pi/controller track how many turns the motor makes, or do you determine speed/duration from testing, then use the limit switch to "return to zero", or something else. Related: Had you also considered using stepper motors for this project?

    4) Could you provide pictures of the linkage between the motor(s) and the frame?

    5) What make of 3D printer do you have, and do you recommend it?

    Much thanks in advance!


    (San Jose, California, US)

    Hi. Very interesting with a solar concentrator!

    My solar tracker will aim the panels in the general direction of the sun. It is not super accurate. A an error of a few degrees is hard to notice.

    I think that your solar concentrator might need more accuracy, so stepper motors will probably be best for you.

    1. At the bottom of step 1 there is a .py file. (Under the photos). Can you check if you see that? Otherwise I need to email it to you. I do not have a premium account for myself.

    2. The motors starts every 10 minutes and moves for a certain time.

    3. The motor does not track how many turns the motor makes. I use speed/duration calculations. I did not use stepper motors since that would be much more expensive.

    4. I will add some photos of the linkage. I made it my self and used a steel sheet and a threaded rod.

    5. I have a Vertex Velleman K8400 and it works great. It cost about 600 dollars and it is a kit that you need to put together yourself.

    Kind regards, Mats

    Here is a photo of the motors that control one of the rows. There is one linear motor for the side-to-side movement, and one motor for the angle movement.


    Love your project. I would like to attempt it. Do you have a link for the Python code for the tracking calcs? Thanks.

    Hi. It was a fun project!

    I used pysolar for the calculations. (Python version 3.5)

    Install pysolar by typing: sudo pip3.5 install pysolar

    Here is the code.

    #for pysolar
    from pysolar import solar
    import datetime

    def GetSunPosition():
    longitude = 12.5350953
    latitude = 59.6365662
    elevation = 55

    when =

    altitude_deg = solar.get_altitude(latitude, longitude, when)

    sun = solar.get_azimuth(latitude, longitude, when, elevation)
    if abs(sun) >= 180:
    sundirection = abs(sun)-180 #Works before noon
    sundirection = abs(sun) + 180 #Works after noon

    print('angle', altitude_deg)
    print('bearing', sundirection)
    return sundirection