mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
only update sensor values if valid and in range
This commit is contained in:
@@ -106,8 +106,12 @@ void Sensors::loop() {
|
||||
case TYPE_DS18S20:
|
||||
case TYPE_DS1822:
|
||||
case TYPE_DS1825:
|
||||
found_.emplace_back(addr);
|
||||
found_.back().temperature_c = get_temperature_c(addr);
|
||||
float f;
|
||||
f = get_temperature_c(addr);
|
||||
if ((f != NAN) && (f >= -55) && (f <= 125)) {
|
||||
found_.emplace_back(addr);
|
||||
found_.back().temperature_c = f;
|
||||
}
|
||||
|
||||
/*
|
||||
// comment out for debugging
|
||||
@@ -220,7 +224,7 @@ float Sensors::get_temperature_c(const uint8_t addr[]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint32_t raw = (raw_value * 625 + 500) / 1000; // round to 0.1
|
||||
uint32_t raw = ((uint32_t)raw_value * 625 + 500) / 1000; // round to 0.1
|
||||
return (float)raw / 10;
|
||||
#else
|
||||
return NAN;
|
||||
|
||||
Reference in New Issue
Block a user