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.



    • Water Contest

      Water Contest
    • Creative Misuse Contest

      Creative Misuse Contest
    • Fix It! Contest

      Fix It! Contest

    25 Discussions

    Excellent project. Love it. Combines several of my hobbies, solar, Pi and DIY projects including wood. If I get the time I’d love to build your prototype. I have a old panel and, spare motorcycle battery plus charge circuit and I have built a couple of Pi projects already. I am a little unsure of the Pi GPIO stuff and how the actuators work. An chance posting where you got the parts so I can see if I can get them. It sure if your still looking after this page but thanks for the inspiration. Maybe one day I’ll get around to it. Would love a larger system in my back garden that I can build on a budget because as you say the overall cost of a solar project is prohibative due to installation costs and I don’t like the idea of adding soar to my house root. A smaller tracker in the back garden would be quite exciting.

    Super nice project, congrats!

    The cost and return of investment is evidently important, but if I think wider, i realise the ecologic benefits : the more energy I produce, the less carbon / nuclear energy must be produced. Also, it helps me not wasting useless energy home (standby TVs, always on routers, etc). It is also highly pedagogical for my kids! :-)

    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.

    1 reply

    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.


    1 year ago

    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.



    2 replies

    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)

    1 reply

    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.


    1 year ago

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

    7 replies

    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

    Thank you for taking the time to respond to my question. I am a novice to Python and am taking a class. I don't have Internet available and am going to have to attach a time module my pi. Would it be possible to get all your code? I really liked the way you controlled the linear actuators. Thank you again.


    Hi. I have attached a file called Servo - for to this instructable. That is all code for my prototype.

    The real system needs internet, I control the application from a website published on my rasperry pi.

    Let me know if my .py contains all you need.

    I used to learn Python. It is free, online training.

    A problem with the raspberry pi is that you need to set the time everytime it is started unless you have internet access. Is that what you need your time module for?

    I let my raspberry pi go online to set it's Clock using NTP.

    Again I appreciate you taking the time for an answer. We are moving to the UK to a remote location. No mains electricity or Internet for miles. Can get mobile data though. But that just gets too complicated to go that route. Hence the need to be off grid with wind and solar. So I will have to use a time module to keep time. My apologies, I did not see the Servo code at first. Thanks again.

    That is a great idea. I will buy a time module and upgrade my own system. Which module will you use? I can get the same kind and let you know when I am done with the code.

    I would like that. I am glad that I can contribute something. I purchased a ChronoDot - Ultra-precise Real Time Clock - v2.1
    PRODUCT ID: 255 from the Adafruit website. It was $17.95. Looking forward to seeing your results.

    Hi. I have recieved my RTC now. I will connect it to my Raspberry PI as soon as I get some spare time. I bought a similar RTC based on the same chip, so the code should work for you as well as soon as I'm done with it.

    He man like your projeckt. It's looking great.

    I have a question: i'm looking for the servo code also. I can seem to find it on your instructable. Can you give me a hint where to look? I have downloaded the PDF, but its not there.

    I like the setup with the Raspberry and using Python with pysolar and I would like to give it a go in the future. Can you help me out?

    Kind regards,


    I have now attached the python code for my prototype to this instructable. Let me know if you have any further questions.