Added inverse operating mode.
When inverse mode is used, the switch is turned on when the temperature excedes the set temperature instead of when it falls below. This is added to control a device like an exhaust fan.
This commit is contained in:
@@ -4,9 +4,13 @@
|
||||
//to identify the device for OTA updates.
|
||||
#define deviceName "Heater"
|
||||
|
||||
//Blynk token for the device that will be providing
|
||||
//the temperature.
|
||||
#define tempDeviceToken ""
|
||||
/*Uncomment the operating mode you wish to use.
|
||||
* Normal - Used for heating. If temp.cur < desired, turn on
|
||||
* Inverse - Operates in the inverse. If temp.cur > desired turn on | This mode could be used for an exhaust fan to limit
|
||||
* temperature or humidity. (Just feed in a humidity value instead of temperature.
|
||||
*/
|
||||
#define normalMode
|
||||
//#define inverseMode
|
||||
|
||||
//Temerature settings
|
||||
Temperature temp = {
|
||||
@@ -29,4 +33,4 @@ int cooldownPeriod = 30;
|
||||
#define loadCooldown 30
|
||||
|
||||
// Attempts before giving up and leaving relay off until reset
|
||||
#define loadConnectAttempts 3
|
||||
#define loadConnectAttempts 3
|
||||
|
||||
+26
-10
@@ -258,19 +258,35 @@ bool cooldownCheck() {
|
||||
}
|
||||
}
|
||||
|
||||
void tempProcess() {
|
||||
if (temp.cur < temp.target && relayState == false) { //If colder than set do next check
|
||||
if (cooldownCheck() == true && temp.cur < temp.target - temp.offset) { //If cooldown has passed and temp is below turn on temp, turn on
|
||||
RelayOn();
|
||||
}
|
||||
} else {
|
||||
if (temp.cur >= temp.target && relayState == true) {
|
||||
RelayOff();
|
||||
timerReset(3); //Reset cooldown timer when turning off relay
|
||||
#ifdef normalMode //Create normalMode process function
|
||||
void tempProcess() {
|
||||
if (temp.cur < temp.target && relayState == false) { //If colder than set do next check
|
||||
if (cooldownCheck() == true && temp.cur < temp.target - temp.offset) { //If cooldown has passed and temp is below turn on temp, turn on
|
||||
RelayOn();
|
||||
}
|
||||
} else {
|
||||
if (temp.cur >= temp.target && relayState == true) {
|
||||
RelayOff();
|
||||
timerReset(3); //Reset cooldown timer when turning off relay
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef inverseMode
|
||||
void tempProcess() {
|
||||
if (temp.cur > temp.target && relayState == false) { //If hotter than set do next check
|
||||
if (cooldownCheck() == true && temp.cur > temp.target + temp.offset) { //If cooldown has passed and temp is above turn on temp, turn on
|
||||
RelayOn();
|
||||
}
|
||||
} else {
|
||||
if (temp.cur <= temp.target && relayState == true) {
|
||||
RelayOff();
|
||||
timerReset(3); //Reset cooldown timer when turning off relay
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void configSave() {
|
||||
EEPROM.write(0,1); //Flag for autoload
|
||||
|
||||
Reference in New Issue
Block a user