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