# Open source code for the maths behind a heliostat?

Theoretically, using a Raspberry Pi, (at least) one mirror, and two motors, one should be able to build a heliostat, i.e. a device which redirects sunlight to a fixed spot, like a scrub in the shadow of a building.

I am now searching for heliostat (open) source code, ideally in python, hopefully with enough comments. Also: Is my following rough approach correct?

1. We need to know the exact geographical location of the mirror in terms of longitude, latitude. For simplicity, we assume that the mirror itself always has an obstacle-free view of the sun.
2. For a given time, we can use celestrial mechanics to calculate the path of the sun on the sky.
3. Using the reflection law from geometrical optics, we can determine the position of the mirror, since we know the vector from the mirror position to the spot we want to direct light to.

That sound simple enough, at least theoretically. I read that for step 2, many use precalculated tables. Why? Is it numerically so challenging?

### References

• You've been through the US Navy site? usno.navy.mil/astronomy Apr 1, 2021 at 14:49
• Part of the reason tables are used for the Sun's position in celestial coordinates is that the right ascension and declination of the Sun vary throughout the year in a complicated way. See the Wikipedia articles on the equation of time and the analemma. Apr 8, 2021 at 20:09
• @MichaelSeifert Thanks for the hint about analemma. I also found Position of the sun which is kind of what I need to do in first place. Apr 8, 2021 at 20:25
• did you build the heliostat? Apr 30 at 18:11
• @jumpjack Not yet. May 2 at 6:50

I wrote the source you need some years ago:

https://jumpjack.wixsite.com/progetti/sorgenti-ipsun

The Arduino/Processing version was just a demo program to manually control a TENVIS camera by multiple buttons, it lacks the "astronomical algorithm".

The Javascript version contains astronomical calculations and a demo page which connects to a local TENVIS camera.

I also built a prototype...

...then I found, at MakerFairRome 2016, a maker which sold on Kickstarter a ready-made heliostat, initially named "Lucy", then renamed "Caia"... but 5 years passed and it has not yet been born... so I think I'll have to go back to my project and develop my own heliostat.

But in the meantime I found this page about a "static heliostat", and now I am trying to reverse-engineer it to figure out if it could be easier/cheaper:

http://cleardomesolar.com/solareflexpanels.html

mirrorAz = TargetAz + (SunAz - TargetAz) / 2