Add resistance property.
This commit is contained in:
parent
2151dda2f9
commit
d6213b35b4
@ -194,19 +194,25 @@ class MAX31865:
|
|||||||
rtd >>= 1
|
rtd >>= 1
|
||||||
return rtd
|
return rtd
|
||||||
|
|
||||||
|
@property
|
||||||
|
def resistance(self):
|
||||||
|
"""Read the resistance of the RTD and return its value in Ohms."""
|
||||||
|
resistance = self.read_rtd()
|
||||||
|
resistance /= 32768
|
||||||
|
resistance *= self.ref_resistor
|
||||||
|
return resistance
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def temperature(self):
|
def temperature(self):
|
||||||
"""Read the temperature of the sensor and return its value in degrees
|
"""Read the temperature of the sensor and return its value in degrees
|
||||||
Celsius.
|
Celsius.
|
||||||
"""
|
"""
|
||||||
raw_reading = self.read_rtd()
|
|
||||||
raw_reading /= 32768
|
|
||||||
raw_reading *= self.ref_resistor
|
|
||||||
|
|
||||||
# This math originates from:
|
# This math originates from:
|
||||||
# http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf
|
# http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf
|
||||||
# To match the naming from the app note we tell lint to ignore the Z1-4 naming.
|
# To match the naming from the app note we tell lint to ignore the Z1-4
|
||||||
|
# naming.
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
|
raw_reading = self.resistance
|
||||||
Z1 = -_RTD_A
|
Z1 = -_RTD_A
|
||||||
Z2 = _RTD_A * _RTD_A - (4 * _RTD_B)
|
Z2 = _RTD_A * _RTD_A - (4 * _RTD_B)
|
||||||
Z3 = (4 * _RTD_B) / self.rtd_nominal
|
Z3 = (4 * _RTD_B) / self.rtd_nominal
|
||||||
@ -220,10 +226,10 @@ class MAX31865:
|
|||||||
temp += 2.2228 * rpoly
|
temp += 2.2228 * rpoly
|
||||||
rpoly *= raw_reading # square
|
rpoly *= raw_reading # square
|
||||||
temp += 2.5859e-3 * rpoly
|
temp += 2.5859e-3 * rpoly
|
||||||
rpoly *= raw_reading # ^3
|
rpoly *= raw_reading # ^3
|
||||||
temp -= 4.8260e-6 * rpoly
|
temp -= 4.8260e-6 * rpoly
|
||||||
rpoly *= raw_reading # ^4
|
rpoly *= raw_reading # ^4
|
||||||
temp -= 2.8183e-8 * rpoly
|
temp -= 2.8183e-8 * rpoly
|
||||||
rpoly *= raw_reading # ^5
|
rpoly *= raw_reading # ^5
|
||||||
temp += 1.5243e-10 * rpoly
|
temp += 1.5243e-10 * rpoly
|
||||||
return temp
|
return temp
|
||||||
|
Loading…
Reference in New Issue
Block a user