|
|
@ -60,8 +60,6 @@ void setup() {
|
|
|
|
//========== Pin setup ==========
|
|
|
|
//========== Pin setup ==========
|
|
|
|
|
|
|
|
|
|
|
|
pinMode(RELAY_PIN, OUTPUT);
|
|
|
|
pinMode(RELAY_PIN, OUTPUT);
|
|
|
|
pinMode(LED_PIN, OUTPUT);
|
|
|
|
|
|
|
|
digitalWrite(LED_PIN, HIGH);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//========== Sensor setup ==========
|
|
|
|
//========== Sensor setup ==========
|
|
|
|
|
|
|
|
|
|
|
@ -84,7 +82,6 @@ void setup() {
|
|
|
|
if(METRICS_EXPORT || API){
|
|
|
|
if(METRICS_EXPORT || API){
|
|
|
|
if(METRICS_EXPORT){
|
|
|
|
if(METRICS_EXPORT){
|
|
|
|
server.on("/metrics", HTTP_GET, [](AsyncWebServerRequest *request){
|
|
|
|
server.on("/metrics", HTTP_GET, [](AsyncWebServerRequest *request){
|
|
|
|
tasker.setTimeout(ledBlink, 10);
|
|
|
|
|
|
|
|
request->send(200, "text/plain; charset=utf-8", metrics);
|
|
|
|
request->send(200, "text/plain; charset=utf-8", metrics);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -172,13 +169,9 @@ void thermostatCheck(){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void readSensor() {
|
|
|
|
void readSensor() {
|
|
|
|
float tempC = sensor.getTempCByIndex(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(tempC != DEVICE_DISCONNECTED_C){
|
|
|
|
|
|
|
|
// read the actual temperature after it's been converted
|
|
|
|
// read the actual temperature after it's been converted
|
|
|
|
temperature = tempC + CORRECTION;
|
|
|
|
temperature = sensor.getTempCByIndex(0) + CORRECTION;
|
|
|
|
// do what you need with the temperature here
|
|
|
|
// do what you need with the temperature here
|
|
|
|
}
|
|
|
|
|
|
|
|
metrics = "temp ";
|
|
|
|
metrics = "temp ";
|
|
|
|
metrics += temperature;
|
|
|
|
metrics += temperature;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -189,8 +182,3 @@ void startConversion() {
|
|
|
|
// schedule reading the actual temperature in 750 milliseconds
|
|
|
|
// schedule reading the actual temperature in 750 milliseconds
|
|
|
|
tasker.setTimeout(readSensor, 750);
|
|
|
|
tasker.setTimeout(readSensor, 750);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void ledBlink() {
|
|
|
|
|
|
|
|
digitalWrite(LED_PIN, LOW);
|
|
|
|
|
|
|
|
delay(200);
|
|
|
|
|
|
|
|
digitalWrite(LED_PIN, HIGH);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|