chefslot:
... Will the code not get confused when between a #, say 30 as it doesn't have an action or a piece of code for this or will it just keep going until another action/criteria has been met, i presume the latter. But i'm now thinking what if the temp jumped from 24 to 30, am i right in thinking that it will not to anything until it then hits 32.
...
No confusion at all. You are right in your assumption. If no criteria is met, relay status will stay as it was.
I do see a possible unexpected behavior.
If t is 25 and h is 73, t wants to activate relay and h want to deactivate relay. Your h>72 statement comes first and is true and relay deactivates. If else is skipped.
Now if h falls to 72, if statement is false and then if else is executed. There t<28 is true and relay activates.
If your next reading of h is 73, relay will immediately deactivate.
One solution to prevent frequent on/off is to use a counter and only activate/deactivate relay after x amount of subsequent readings.
Written in notepad, might contain spelling errors and other faults.
byte relayLowCounter=0; //declare global, use int if more than ~4 minutes is needed.
byte relayHighCounter=0;
...
if (t > 32 || h > 72 ) {
//digitalWrite(Relay1, LOW);
relayLowCounter++;
relayHighCounter=0;
}
else if (t < 28 || h < 68 ) {
//digitalWrite(Relay1, HIGH);
relayHighCounter++;
relayLowCounter=0;
}
if (relayLowCounter>60){ // 60 for ~1 minute
digitalWrite(Relay1, LOW);
}
else if (relayHighCounter>60){
digitalWrite(Relay1, HIGH);
}