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