thanks for that! it will take me some time to work through it

a question: in your “how to” on your web page, you say:

link the sensor to the actuator

i think this shoud be 'link the sensor to the controller"?

about the sun_engine.py script:

to simplify, some functions are not used and could be removed from the script. for example, “isBisestile”, “Julian”.

also, imo it doesn’t make sense to include seconds…the calcs are not that accurate…

now, about the moon. here is a little patch which calculates moon positions. one good thing is, the source is the same as for fiat_lux. i have kept variable, function names etc the same as in fiat_lux. the results are generally quite accurate (3 or 4 degrees) but in some cases, i have noticed a variation as high as 9 degrees. i will look into it a bit deeper. there’s a good javascript page here for calculating sun and moon positions as reference:

```
# calculates moon positions.
# calcs sourced from http://www.astro.uu.nl/~strous/AA/en/reken/hemelpositie.html#maan
# intended as a patch for sun_engine.py
# the initial defs, variables etc are only required to run this as a stand-alone script.
import math
from math import floor, radians as rad, degrees as deg, sqrt
def cos(x):
return math.cos(rad(x))
def sin(x):
return math.sin(rad(x))
def arcsin(x):
return deg(math.asin(x))
def tan(x):
return math.tan(rad(x))
def atan(x):
return deg(math.atan(x))
def atan2(x, y):
return deg(math.atan2(x, y))
def AngleNorm(angle):
'''Normalizes an angle between 0 and 360 degrees
'''
return angle % 360.0
def B60toB10(pris, mins):
'''Converts from base 60 to base 10
'''
return pris + mins / 60.0
def Greg2J(Day, Month, Year, Hour, Minute):
'''Converts from Gregorian dates to Julian dates
'''
time_dec = B60toB10(Hour, Minute) / 24.0
day_dec = Day + time_dec
if Month < 3:
Month += 12
Year -= 1
c = 2 - floor(Year / 100) + floor(Year / 400)
JD = floor(1461 * (Year + 4716) / 4) + floor(153 * (Month + 1) / 5) + day_dec + c - 1524.5
return JD
Lat, Long = 48.87, -2.33
Day, Month, Year, Hour, Minute = 12, 12, 2009, 17, 0
JD2000 = 2451545
JD = Greg2J(Day, Month, Year, Hour, Minute)
# geocentric ecliptic longitude, equinox, mean anomaly
ML = 218.316 + 13.176396 * (JD - JD2000)
MM = 134.963 + 13.064993 * (JD - JD2000)
MF = 93.272 + 13.229350 * (JD - JD2000)
# geocentric ecliptic coordinate, moon longitude, moon latitude
MLong = ML + 6.289 * sin(MM)
MLat = 5.128 * sin(MF)
#print AngleNorm(MLong), AngleNorm(MLat)
# Moon's equatorial coordinates
RA = atan2(sin(MLong) * cos(23.45), cos(MLong)) # right ascension
Decl = arcsin(sin(MLong) * sin(23.45)) # declination
# Sidereal time at location
ST = 280.1600 + 360.9856235 * (JD - JD2000) + Long
ST = AngleNorm(ST)
H = ST - RA
# Moon's Azimuth
mazimuth = atan2(sin(H), cos(H) * sin(Lat) - tan(Decl) * cos(Lat)) + 180
# Moon's Altitude
maltitude = arcsin(sin(Lat) * sin(Decl) + cos(Lat) * cos(Decl) * cos(H))
print mazimuth, maltitude
```