|
|
|
@ -24,6 +24,7 @@ DallasTemperature sensor(&oneWire);
|
|
|
|
|
|
|
|
|
|
float temperature;
|
|
|
|
|
String metrics;
|
|
|
|
|
bool heating;
|
|
|
|
|
float reqTemp = 21.5;
|
|
|
|
|
float offset = 0.25;
|
|
|
|
|
|
|
|
|
@ -127,13 +128,13 @@ void setup() {
|
|
|
|
|
String repply;
|
|
|
|
|
|
|
|
|
|
if(request->hasParam("temp")) {
|
|
|
|
|
repply = temperature;
|
|
|
|
|
repply = String(temperature);
|
|
|
|
|
}else if(request->hasParam("relay")){
|
|
|
|
|
repply = !digitalRead(RELAY_PIN);
|
|
|
|
|
repply = String(heating);
|
|
|
|
|
}else if(THERMOSTAT && request->hasParam("reqtemp")){
|
|
|
|
|
repply = reqTemp;
|
|
|
|
|
repply = String(reqTemp);
|
|
|
|
|
}else if(THERMOSTAT && request->hasParam("offset")) {
|
|
|
|
|
repply = offset;
|
|
|
|
|
repply = String(offset);
|
|
|
|
|
}else{
|
|
|
|
|
repply = "unknown parameter";
|
|
|
|
|
}
|
|
|
|
@ -165,9 +166,11 @@ void notFound(AsyncWebServerRequest *request) {
|
|
|
|
|
|
|
|
|
|
void thermostatCheck(){
|
|
|
|
|
if(temperature < (reqTemp - offset)){
|
|
|
|
|
digitalWrite(RELAY_PIN, false);
|
|
|
|
|
heating = 1;
|
|
|
|
|
digitalWrite(RELAY_PIN, !heating);
|
|
|
|
|
}else if(temperature > (reqTemp + offset)){
|
|
|
|
|
digitalWrite(RELAY_PIN, true);
|
|
|
|
|
heating = 0;
|
|
|
|
|
digitalWrite(RELAY_PIN, !heating);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -181,6 +184,15 @@ void readSensor() {
|
|
|
|
|
}
|
|
|
|
|
metrics = "temp ";
|
|
|
|
|
metrics += temperature;
|
|
|
|
|
metrics += "\nraw_temp ";
|
|
|
|
|
metrics += tempC;
|
|
|
|
|
metrics += "\nheating ";
|
|
|
|
|
metrics += heating;
|
|
|
|
|
metrics += "\nreqTemp ";
|
|
|
|
|
metrics += reqTemp;
|
|
|
|
|
metrics += "\noffset ";
|
|
|
|
|
metrics += offset;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void startConversion() {
|
|
|
|
|