Finding Dusk Time #9642
Replies: 3 comments 4 replies
-
If you need this much more accurately than ±5 minutes or so, MicroPython's maths handling may not be accurate enough for you. I don't know of a module that explicitly calculates dusk (any of the civil, nautical or astronomical twilights), but Dan J Perron put a simple module here that calculates sunrise and sunset. The start of twilight doesn't vary a huge amount from sunset over the year, but the amount depends on your latitude. Note that MicroPython's time zone handling is not very advanced. Typically, localtime will always return the same as gmtime. We're a very small system, after all. |
Beta Was this translation helpful? Give feedback.
-
I have a small application that runs on Python on a Raspberry Pi that does this. I just fetch the sunrise/sunset times from https://sunrise-sunset.org/api. |
Beta Was this translation helpful? Give feedback.
-
In addition to the Wikipedia article mentioned, there is another page: https://sciencing.com/calculate-suns-declination-6904335.html that lays out step by step how to do the calculations. I used the information there to create a sunrise sunset calculator that might fit what you're looking for. Unfortunately, it's written in JavaScript, not Python. But, it's heavily commented and should be able to serve as an example of the math involved if you wanted to write your own. |
Beta Was this translation helpful? Give feedback.
-
Python can import Astral to find various astronpmical times, such as dusk time for your location. Is there an equivalent with micropython? If not is there another way to do this without resorting to tables?
Beta Was this translation helpful? Give feedback.
All reactions