hello Setting up a reef tank and i have most code i think i need...? issues in my head with how seasons need to be read from rtc. i have included the file so you can see how its actually gonna work. Shortcuts would be awesome to learn..
if((month=<6 && dayOfWeek=<19)||(month=>3 && dayOfWeek=<20)||(month=>3 && month=<5)) else if // spring
{
}
elseif ((month=<9 && dayOfWeek=<21)||(month=>6 && dayOfWeek=<20)||(month=>7 && month=<8)) else if // summer
{
}
elseif ((month=<12 && dayOfWeek=<20)||(month=>9 && dayOfWeek=<22)||(month=>10 && month=<11)) else if // fall
{
}
elseif ((month=<3 && dayOfWeek=<19)||(month=>12 && dayOfWeek=<21)||(month=>1 && month=<2)) else if // winter
{
}
Even assuming you are in the northern hemisphere, your code won't work. For example, for Jan 1st (month ==1, dayOfWeek == 1) it will determine it's spring (first if condition is true).
if((month=<6 && dayOfWeek=<19)||(month=>3 && dayOfWeek=<20)||(month=>3 && month=<5)) else if // spring
The condition in the if statement is true when month==1 and dayOfWeek==1, isn't it?
At the end, you make the comment "spring", so I assume you are going to execute something specific to spring, are you not?
switch (month)
{
case 1: // January
case 2: // and February
season = summer;
break;
case 3: // March
if (day >= 21)
season = autumn;
else
season = summer;
break;
// ... and so on
} // end of switch
I live in the southern hemisphere BTW, which is why it is autumn right now.
one thing about me is (and people may come to notice...) i really hate to over-complicate ANYTHING eg if it's not needed or an alternative is there take it anything reduce your memory usage or binary size.
but, and my understanding could be way off here.. but.. am I right in understanding you want certain actions depending on the time of year? eg if it's summer more daylight therefor the the lights come on at different times of the day, so the RTC is read and through a series of calculations you know exactly when to switch on and off the lights and other things like pumps and stuff.
if so?.. why an RTC at all?
run a cable (or invest in another small arduino with 2 wireless modules) to a window and on the end of the cable attach a photo resistor, feed the other end into your analogue in and read the values appropriately, or use another arduino to relay back the information if you want a clean setup... now when it "goes dark" or cloudy or a storm approaches and it's dark at 3pm, you don't need to guess what's going on, you actually have real world data coming in, based on how much light there is, you switch the lights on or off.
Now having said all that i could be completely wrong and you have to use the RTC and you can't use say a Temperature Sensor and Light Sensor to fully automate it.. imagine if street lamps only came on at a certain times based on the year date and time, no to consistently get it come on as it goes dark be the middle of the day or night time, a light sensor is used.
Another approach would be to take the date, turn it into a Julian date (ie. day of year) ... I think there are quite a few short algorithms for that. Then simply do a straight compare. There will only be 4 break points then.
And here's another idea ... by reading in sunlight you can deduce the season. For example, very short days ... winter.
yeah, store how much light comes in and at the end of the day store it onto the eeprom, to get number hours of light, like it, very short days = nuclear winter (or just plain old winter)
I had originally laid out the sketch I sequence of operation after delving into the if else
Statement I realized that if the times are true then fan will be off and else it would be off.
I have off tomorrow and will be posting better sketchhooefully. I will be controlling a metal halide,fan ,compact fluorescent, led and (2power heads that
Will be on a 15min alternating cycle.900,000millis.
I know I'm making it harder on myself then it needs to be but my programming days are years behind me and it was c++. With the tank my dad built I thought no better time than now to get back into it.