send -1 if coloretemp not ok

This commit is contained in:
interfisch 2020-11-01 20:20:03 +01:00
parent 87a095015c
commit 1422636c6b
1 changed files with 4 additions and 4 deletions

View File

@ -259,7 +259,7 @@ void setup() {
#ifdef SENSOR_BMP180 #ifdef SENSOR_BMP180
Serial.println("initializing bmp180"); Serial.println("initializing bmp180");
if (!bmp180.begin()){ if (!bmp180.begin()){
Serial.println("#ERROR: BMP180 init fail\n\n"); Serial.println("#ERROR: BMP180 init fail\n");
}else{ }else{
bmp180init_ok=true; //stays false if init failed, sensor will not be read in loop bmp180init_ok=true; //stays false if init failed, sensor will not be read in loop
} }
@ -947,9 +947,11 @@ void loop_TCS34725_colortemp()
sensorNode.setProperty("colortemp").send(String(value_colortemp)); sensorNode.setProperty("colortemp").send(String(value_colortemp));
}else{ }else{
Homie.getLogger() << "didn't send tcs ct because value is too low" << endl; Homie.getLogger() << "didn't send tcs ct because value is too low" << endl;
sensorNode.setProperty("colortemp").send(String(-1));
} }
}else{ }else{
Homie.getLogger() << "didn't send tcs ct because light too low: " << tcs.lux << "lux" << endl; Homie.getLogger() << "didn't send tcs ct because light too low: " << tcs.lux << "lux" << endl;
sensorNode.setProperty("colortemp").send(String(-1));
} }
d.lastsentvalue=value_colortemp; d.lastsentvalue=value_colortemp;
@ -1010,11 +1012,9 @@ void loop_raingauge()
}else{ }else{
value_raingauge=3600000/(millis()-raingauge_lasttimereset)/raingauge_pulsecounter*RAINGAUGE_FLIPAMOUNT; value_raingauge=3600000/(millis()-raingauge_lasttimereset)/raingauge_pulsecounter*RAINGAUGE_FLIPAMOUNT;
} }
}
if (abs((int)d.lastsentvalue-value_raingauge)>=d.minchange){ //int abs //for raingauge minchange should be 0 (send every change)
_changed=true; _changed=true;
} }
d.lastreadtime=millis(); d.lastreadtime=millis();
} }