mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
52_I2C_LM75A: neue Version auf 0.125°C genau gerechnet (NXP-Sensorem)
git-svn-id: https://svn.fhem.de/fhem/trunk@15048 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4d666fa384
commit
3041cb6548
@ -196,9 +196,13 @@ sub I2C_LM75A_GetTemp ($$) {
|
|||||||
if(($raw[0] & 0x80) > 0) {
|
if(($raw[0] & 0x80) > 0) {
|
||||||
$temperature = 0xffffff00;
|
$temperature = 0xffffff00;
|
||||||
}
|
}
|
||||||
$temperature |= ($raw[0] & 0x7f) << 1;
|
# $temperature |= ($raw[0] & 0x7f) << 1;
|
||||||
$temperature |= (($raw[1] >> 7) & 1);
|
# $temperature |= (($raw[1] >> 7) & 1);
|
||||||
$temperature = $temperature / 2;
|
|
||||||
|
my $temperature_11_bit = ($raw[0]<<8 | $raw[1]) >> 5; # Compute 11-bit temperature output value
|
||||||
|
$temperature = ($temperature_11_bit) * 0.125; # Compute temperature in °C
|
||||||
|
|
||||||
|
# $temperature = $temperature / 2;
|
||||||
Log3 $hash, 5, "temperature: $temperature";
|
Log3 $hash, 5, "temperature: $temperature";
|
||||||
$temperature = sprintf(
|
$temperature = sprintf(
|
||||||
'%.' . AttrVal($hash->{NAME}, 'roundTemperatureDecimal', 1) . 'f',
|
'%.' . AttrVal($hash->{NAME}, 'roundTemperatureDecimal', 1) . 'f',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user