Skip to content

Commit

Permalink
checkval
Browse files Browse the repository at this point in the history
  • Loading branch information
markirb committed Jun 10, 2024
1 parent 8ccdc21 commit b2666e0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/DHT/shelly_dht_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,20 @@ StatusOr<float> DHTSensor::GetHumidity() {
}

void DHTSensor::UpdateTemperatureCB() {
// std::nan
result_ = mgos_dht_get_temp(dht);
result_humidity_ = mgos_dht_get_humidity(dht);
float result = mgos_dht_get_temp(dht);
float result_humidity = mgos_dht_get_humidity(dht);

// check values for validity
if ((result == 0) and (result_humidity == 0) or isnan(result) or
isnan(result_humidity)) {
// error during readout do nothing for now
LOG(LL_INFO, "DHT: invalid value received");
return;
}

result_ = result;
result_humidity_ = result_humidity;

if (notifier_) {
notifier_();
}
Expand Down

0 comments on commit b2666e0

Please sign in to comment.