52_I2C_HDC1008.pm: further plausibility check for read values

According to datasheet of HDC1008 and HDC1080, least two bits of temp
and hum register shall always be "0", so ignore value if we see another
value there. This seems to finally eliminate sporadic readings of 125°C
and/or 100% rH.



git-svn-id: https://svn.fhem.de/fhem/trunk@16705 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
yoda_gh
2018-05-07 21:10:32 +00:00
parent a090b59636
commit 477faddec5

View File

@@ -192,6 +192,10 @@ sub I2C_HDC1008_GetTemp ($$)
my @raw = split(" ",$rawdata);
my $tempWord = ($raw[0] << 8 | $raw[1]);
if ( ($tempWord & 0x3) != 0 ) {
Log3 $hash, 4, "[$name] I2C_HDC1008_I2CRec invalid temperature raw value: $tempWord";
return undef;
}
my $temperature = (($tempWord /65536.0)*165.0)-40.0;
@@ -210,7 +214,11 @@ sub I2C_HDC1008_GetHum ($$)
my @raw = split(" ",$rawdata);
my $humWord = ($raw[2] << 8 | $raw[3]);
if ( ($humWord & 0x3) != 0) {
Log3 $hash, 4, "[$name] I2C_HDC1008_I2CRec invalid humidity raw value: $humWord";
return undef;
}
my $humidity = ($humWord /65536.0)*100.0;
Log3 $hash, 5, "[$name] I2C_HDC1008_I2CRec calced humidity: $humidity";