Method: Denko::Sensor::DS18B20#decode_temperature

Defined in:
lib/denko/sensor/ds18b20.rb

#decode_temperature(bytes) ⇒ Object

Temperature is the first 16 bits (2 bytes of 9 read). It’s a signed, 2’s complement, little-endian decimal. LSB = 2 ^ -4.



62
63
64
# File 'lib/denko/sensor/ds18b20.rb', line 62

def decode_temperature(bytes)
  bytes[0..1].pack('C*').unpack('s<')[0] * (2.0 ** -4)
end