# Sunrise and Sunset - injecting current position

**URL:** <https://discourse.nodered.org/t/sunrise-and-sunset-injecting-current-position/101573>\
**Category:** General\
**Created:** [31 July 2026 15:48 UTC](https://discourse.nodered.org/t/sunrise-and-sunset-injecting-current-position/101573 "2026-07-31T15:48:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [31 July 2026 15:48 UTC](https://discourse.nodered.org/t/sunrise-and-sunset-injecting-current-position/101573/1 "2026-07-31T15:48:03Z")

</div>

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.

TIA,  
Colin J

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [31 July 2026 16:27 UTC](https://discourse.nodered.org/t/sunrise-and-sunset-injecting-current-position/101573/2 "2026-07-31T16:27:51Z")

</div>

I _think_, looking at its help panel, that CRON+ lets you set that via input msg which would probably be the first step?

Yup:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8ddd4e9ff268ecc53c0aefe68514bbc80855fec1.png)

I think you use a dynamic schedule. There is some example JSON shown towards the end of the help panel.

Also see the solar events example in the library that you can import.

---

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [31 July 2026 16:43 UTC](https://discourse.nodered.org/t/sunrise-and-sunset-injecting-current-position/101573/3 "2026-07-31T16:43:40Z")

</div>

Thanks Julian, I will investigate.

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!!

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [31 July 2026 16:46 UTC](https://discourse.nodered.org/t/sunrise-and-sunset-injecting-current-position/101573/4 "2026-07-31T16:46:31Z")

</div>

The cron plus node has example flows you can import.

The "Solar events" flow includes the sunrise time of two places whose latitude and longitude are passed in as msg.payload.location.

---

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [31 July 2026 17:10 UTC](https://discourse.nodered.org/t/sunrise-and-sunset-injecting-current-position/101573/5 "2026-07-31T17:10:40Z")

</div>

Got it! Thank you.

I have been looking at all of these Nodes and just couldn't see how to do it. Seemed I could change everything other than location!

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [1 August 2026 00:19 UTC](https://discourse.nodered.org/t/sunrise-and-sunset-injecting-current-position/101573/6 "2026-08-01T00:19:50Z")

</div>

Not to step on Paul's solution.

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 August 2026 00:19 UTC](https://discourse.nodered.org/t/sunrise-and-sunset-injecting-current-position/101573/7 "2026-08-15T00:19:58Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
