I have NR installed on a WYSE3040 in my Motorhome. I have also used several Nodes to get Sunrise and other Astronomical events. All of these nodes ask me to put my current position, which is fine for home, I get the Lat and Long from a map and input them, no problem.
My problem is that the Motorhome moves and I need/(would like) to put in my Lat and Long for each position I am at to get accurate times. This is a pain, especially when I can get the Lat and Long from my Router, which has a GPS Module and, along with MQTT, gives me my current position.
I have looked, but I can't see if this injection of current position is possible with any of the available Nodes, unless of course, anyone knows different and can help me figure it out.
I thought that CRON+ was the most likely, but couldn't see the wood as there are many, many trees!! I must admit, it is my goto when looking for times and events!!
I did this on an Arduino project a long time ago.
I can't find THE code - shame on me.
But a quick dig on the internet I get this:
I think you're probably remembering the Sunrise Equation in its most compact form.
Many implementations boil the entire calculation down to a single equation that returns the hour angle, and then convert that directly to minutes after midnight.
A very common version is:
cosω=
cosϕcosδ
sin(−0.833
∘
)−sinϕsinδ
where:
ϕ = latitude
δ = solar declination for the date
ω = hour angle
Then:
sunrise = 720 - 4(longitude + ω°) - E
sunset = 720 - 4(longitude - ω°) - E
where:
longitude is in degrees (east positive)
E is the Equation of Time (minutes)
the result is minutes after midnight UTC.
Notice how compact that is: once you know δ and E for the day, it's literally just two formulas.
You receive the lat/long from the GPS and just plug the numbers into this formula.