So there’s a nice project for the mathematically inclined. My ESP boards get the time (summer time and location corrected) via MQTT where that’s worked out on a more powerful Raspberry Pi. They also get dusk and dawn times.
As it is possible on the ESP to get the time via NTP, and it is easy to add the regional offset, all that is missing is summer/winter time correction and dusk and dawn times in a stand-alone environment. I found one piece of code which looked like it might do the job but it would not compile as all the various floating point libraries such as sin/cosine etc. etc. are all missing.
Is there another way to get local, summer adjusted time and date along with lighting up and dawn times, from a server without having to do lots of maths locally. Clearly one could write something on a server somewhere in PHP to do the job – but that might be re-inventing the wheel?
Hi Peter/everyone,
I’ve been looking for a solution for my problem on your site and code but cant find any. I’m using the Eclipse development platform and i’m trying to find similar implementation used on Arduino IDE for the function “millis()” so to check time lapsed from a point on the function to the other and cant really see how to do that (basically implementing a timeout in the order of the milliseconds and not seconds). Your RTC implementation gives the tm.seconds and i could use that but i need on the order of the milliseconds is it at all possible? Thanks again in advance.
Never mind found the answer myself. For a future ‘me’ with same question the answer is system_get_time(). Cheers
You could also try http://www.wunderground.com/weather/api for the sunset/sunrise data and more. There is a free developer option which maybe of help to you.
DST is pretty simple in Western Europe: changes take place the last Sunday from month of March and October at 1:00 am UTC, here are simple the formulas:
https://en.wikipedia.org/wiki/Summer_Time_in_Europe
If it were me (and it might be soon) I would re-implement the sine/cosine stuff as several level deep Taylor expansions (just requires arithmetic). Care to point at the code you were looking at?
how about this http://timezonedb.com/api
You are now officially my hero!
Or maybe something like this https://github.com/mojombo/chronic