Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Smart Thermostat Arduino - part thermostat functions
//function to determine if boiler controll loop should go to run level 1
int frunScen (int actTemp, int setTemp) {
if ( (setTemp*10) - actTemp > 35) {
return 1;
} else {
return 0;
}
}
//function to determine how many seconds boiler should go on within 10 minute interval
unsigned long fscenLength(int actTemp, int setTemp) {
unsigned long scnel;
// int iscnel = 0;
if ( (setTemp*10) - actTemp > 260) {
scnel = (6UL*60UL*1000UL);
} else if ( (setTemp*10) - actTemp > 160) {
scnel = (5UL*60UL*1000UL);
} else if ( (setTemp*10) - actTemp > 70) {
scnel = (4UL*60UL*1000UL);
} else if ( (setTemp*10) - actTemp > 40) {
scnel = (3UL*60UL*1000UL);
} else {
scnel = (2UL*60UL*1000UL);
}
return scnel;
}
//function to check if boiler should stay on or go off
int fboilerStat(unsigned long starts,unsigned long scenl,unsigned long cur ,int actTemp, int setTemp) {
if (actTemp - (setTemp*10) < 35){ //criteria 1: only say on if act temperature is below set temperature + margin
if (cur - starts < scenl) { //criteria 2: only stay on of boiler has not been on for the number of seconds determined by fscenLength
return 1; //stay on
} else {
return 0; //go off (because boiler was on for number of minues determined by fscenLength
}
} else {
return 2; //go off (2 is used to monitor overflow)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.