2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

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:
gernot-h 2018-05-07 21:10:32 +00:00
parent 716a795bcd
commit 5fa96ec623

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,6 +214,10 @@ 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;