added thermostat logic task

master
David Zálešák 4 years ago
parent 5340a0fae2
commit 72a0df2444

@ -71,9 +71,12 @@ void setup() {
startConversion(); // First temp read startConversion(); // First temp read
tasker.setInterval(startConversion, 15000); // read temperature every 15 seconds tasker.setInterval(startConversion, 15000); // read temperature every 15 seconds
//tasker.setTimeout(relayLoop, 5000);
tasker.setInterval(otaHandle, 1000); tasker.setInterval(otaHandle, 1000);
if(THERMOSTAT){
tasker.setInterval(thermostatCheck, 1000);
}
//========== Web server setup ========== //========== Web server setup ==========
if(METRICS_EXPORT){ if(METRICS_EXPORT){
@ -160,12 +163,13 @@ void notFound(AsyncWebServerRequest *request) {
request->send(404, "text/plain", "Not found"); request->send(404, "text/plain", "Not found");
} }
//void relayLoop(){ void thermostatCheck(){
// byte pin = RELAY_PIN; if(temperature < (reqTemp - offset)){
// bool led = !digitalRead(pin); digitalWrite(RELAY_PIN, true);
// digitalWrite(pin, led); }else if(temperature > (reqTemp + offset)){
// tasker.setTimeout(relayLoop, led ? 3000 : 7000); digitalWrite(RELAY_PIN, false);
//} }
}
void readSensor() { void readSensor() {
// read the actual temperature after it's been converted // read the actual temperature after it's been converted