Arduino Sun Tracking / Heliostat Electronics Control System

Subscribe to my Feed!

UPDATE: Much of the information on this page in now horribly out of date. The most up to date information can be found on this page on this site’s forums.


The rat nest of wires and electronics you see in the picture below is what I use to control my heliostats.  This page will give you an overview on how it all works and information for putting together your own heliostat / sun tracking control system.

This is what I use, but there are a lot of variations on it that could also work. I’m not an electronics expert, so don’t take my way as necessarily being the absolute best way. In fact, I’m sure it isn’t. I do know that it works though, so I don’t complain.

Although it might look complicated to the uninitiated, it is really only made up of several simpler circuits. Also, depending on your application, you might even be able to leave out parts of it.

Sun Tracking Circuit


The most vital componant in this circuit is, of course, the Arduino. There are many different types of Arduino boards, as you can see from this link I am using the Arduino Duemilanove, but the more recent Arduino Uno and either of the Arduino Mega boards should be fine, and possibly other boards too. Using the Arduino Mega, however, will require some changes to the Arduino Sun Tracker program. These changes would likely only involve simple pin reassignment, but other unforseen issues could, of course, always come up. If anybody tries it, let me know how it goes.

Some of the older Duemilanove Arduinos have the ATmega168 installed. I am doubtful that this chip has enough space for the Arduino Sun Tracker program, so make sure you have one with the ATmega328p.

The Arduino is an 8-bit microcontroller. The result of only having 8 bits is that the level of mathematical precision is diminished to no more than that of a float. To quote the Arduino site, “Floats have only 6 -7 decimal digits of precision. That means the total number of digits, not the number to the right of the decimal point. Unlike other platforms, where you can get more precision by using a double (e.g. up to 15 digits), on the Arduino, double is the same size as float.” The formulas for calculating the sun’s position are, well, astronomical, so having double precision is pretty much required to get any of the good sun position calculating algorithms to return correct results.

I designed the Arduino Sun Tracker program to work around this issue by using a lookup table, and for most hobbyists it should be perfectly fine. If you want, for whatever reason, to obtain more precision for all of the various calculations inside the Arduino Sun Tracker program, you might consider looking into this Arduino compatable 32-bit microcontroller and the sun position algorithms featured on this page of my site. Note: The Ruby program would have to be converted to work with the Arduino.

I have never used the Maple 32-Bit Arduino Compatable Microcontroller, so I’m uncertain as to how difficult it would be to make the Arduino Sun Tracker program work with it. It may be as easy as just loading the sketch as is, but, in reality, there’s no telling what issues might need to be worked through. If anybody gets it to work, please consider sharing the code!

DS1307 Real Time Clock

The first thing I added to my Arduino was a DS1307 Real Time Clock. The time is used when calculating the sun’s position, so it is important that it is kept accurately. There is, in fact, a library for the Arduino that will allow it to keep track of the time without the RTC, but using it would require modifying the Sun Tracking / Heliostat program. The RTC should be more accurate than the Arduino, and it also has a battery backup, so the time doesn’t have to be set everytime the Arduino is reset.

To learn how to wire the DS1307 Real Time clock to the Arduino, check out this site This is where I myself learned how to use it. It is also where the code for controlling the DS1307 in the “Arduino Sun Tracker” sketch comes from.

I bought my first DS1307 from Sparkfun. Here is the link

At one point I thought that I had accidentally fried it after plugging it into the wrong holes in my solderless breadboard when testing the circuit. Turns out that I had only managed to quickly drain the battery, and it worked again after I swapped it for a new one.

In any case, I bought a second RTC from this link. It’s a little cheaper, but you have to solder it together.

At the same site, there is also the ChronoDot. The ChronoDot is designed to be more accurate than the above RTC and will maintain the correct time for a longer period of time. It is supposed to be basically the same as the above RTC, so it should theoretically work with the Arduino Sun Tracking / Heliostat program without requiring any of the code to be rewritten. If anybody out there tries it and finds that it works, let me know so I can reccommend it.

Driver Board

I use two simple DIY driver boards to power the stepper motors. Since I am controlling multiple heliostats, I use relays to turn the power on and off between different sets of motors. This way I can essentially control as many stepper motors as I could ever practically need while still only using just the two driver boards.

I have the Schematics and pictures for the driver board I am using on this page DIY Arduino Stepper Motor Driver Board.

It is possible to buy already assembled driver boards at various places online, but I’m not sure what I would recommend for this application. The driver boards that I have used personally keep the stepper motors powered on constantly. Since the whole point of this project is to reduce energy consumption, it doesn’t seem very smart to leave them on 24 hours a day.

If you are using relays to control multiple solar machines like I am, these types of driver boards have another disadvantage. With the power left on, the relays will spark across their contacts every time they are turned on or off. This sparking will reduce the life of the relays.

Shift Registers

The Arduino has a limited number of outputs but more can be added by using shift registers. I use two of them with my Arduino for 16 additional output pins (not counting the few that are used up on the Arduino to control the shift registers).

I use these pins to turn relays on and off, one at a time. Each time a relay turns on, power is supplied to another pair of stepper motors and the driver board is then able to control another solar machine. Since I have 16 outputs, I can control 16 different machines.

I stopped at two shift registers, but more can be chained together to give even more outputs. This would theoretically allow me to control as many solar machines as I could ever practically need.

Of course, depending on the number of outputs you have leftover on your Arduino and the number of machines you want to control, you might not need to bother with shift registers at all. You may need to modify the Arduino Sun Tracker sketch slightly for this to work though.

The circuit for attaching the shift registers to the Arduino can be found on the Arduino website at Try it out with the LEDs first to make sure you have it working. Once it’s finished, you can swap the LEDs for the relays. IMPORTANT: This is written in big bold letters because you will be confused if you miss it. The latch pin in the circuit at the link (green wire) needs to be attached to pin 10 instead of pin 8 when using the Arduino Sun Tracking program. It was moved because it was in the way of the stepper motor wires.

Here is the link to where I bought my shift registers.

I haven’t tried it, but it should also be possible to use an Arduino Mega instead of the shift registers to extend the number of outputs. It would require the Arduino Sun Tracker Sketch to be modified though.


It is possible to control multiple solar machines without having to add more driver boards by using relays.

I have the schematic for the relay circuit I used along with information on how it works on the page Using Relays to Control Multiple Solar Machines.

Limit Switches

Wiring the limit switches is pretty straight forward. The schematic below shows how to do it. If you only have one machine, you only need one pair of switches. To add more though, you just have to wire more pairs of switches parallel with the first pair. The pin used on the Arduino for the limit switches is pin 13. This is the default in the Arduino Sun Tracker Program, but it can be changed easily if needed.

Switches for Changing Heliostat Targets

The switches are only necessary if you are controlling a heliostat(s) and want to be able to switch between different targets. This isn’t by any means the only way of accomplishing this, it’s just how I, somewhat arbitrarily, decided to do it.

Check out the page Switches for Changing Heliostat Targets to see how I have them wired to my Arduino.

Unipolar Stepper Motors

I found my unipolar stepper motors on eBay and managed to get a lot of 12 for about $35. This gives me enough to make six different solar machines. They work fine for what I’m using them for, but they have a low resolution of 7.5 degrees per step. Even with the low resolution though, they have been fine precision wise.

The exact type is Astrosyn Stepper 28BB-H151-11. I actually tried these stepper motors with two different driver boards that I had purchased and, for whatever reason, they didn’t work. They work fine with the driver board I explained above though.

There are obviously many different types of stepper motors out there that will get the job done equally well.

Astrosyn Stepper 28BB-H151-11

Subscribe to my Feed!