I’m working on a “Farm Automation” project. It prioritises satisfying the demand for water from humans, stock, and trees from a number of water sources. In the case of trees, I don’t want to water them (or irrigate in general) in winter time. I need to be able to access the date and I’ve decided to do that by accessing GPS. I need to be able to identify winter/summer time and I’m doing that by determining standard time (which is winter time) and daylight saving time (DST, which is summer time). Irrigation is only allowed to operate in summer time. I also have a season-override switch incase climate change delivers severe rain in summer time.
I am using Slash Devlin’s suite of GPS software https://platformio.org/lib/show/1247/NeoGPS/examples?file=NMEAtimezone.ino and in particulat NMEAtimezone.ino for the DST switch.
Regretably, NMEAtimezone.ino isn’t working. Sorry Slash. I have done a huge amount of work and I have discovered the following which I wanted to show you. You need to know, I live in New Zealand, ie southern hemisphere.
The key piece of code is -
if ((springForward <= seconds) && (seconds < fallBack)) then …
Remembering that the dates for DST (and its reversal) are calculated once annually (or on reset), what this code says is that if today, right now in, seconds falls after the spring change and before the autumn fallback (in seconds) then execute the condition. Problem is that in the southern hemisphere in any calander year, autumn falls BEFORE spring so the (if) condition will never be satisfied using this existing code.
So my southern hemisphere replacement code is -
if (seconds < autumnBack || seconds >= springForward)
seconds += NeoGPS::SECONDS_PER_HOUR;
This whole suite is working wonderfully for me, now.
Heck! I hope I’ve got this right.