File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -102,8 +102,8 @@ def __init__(
102
102
self .high_side = high_side
103
103
104
104
@property
105
- def temperature (self ):
106
- """The temperature of the thermistor in Celsius """
105
+ def resistance (self ):
106
+ """The resistance of the thermistor in Ohms """
107
107
if self .high_side :
108
108
# Thermistor connected from analog input to high logic level.
109
109
reading = self .pin .value / 64
@@ -112,8 +112,12 @@ def temperature(self):
112
112
else :
113
113
# Thermistor connected from analog input to ground.
114
114
reading = self .series_resistor / (65535.0 / self .pin .value - 1.0 )
115
+ return reading
115
116
116
- steinhart = reading / self .nominal_resistance # (R/Ro)
117
+ @property
118
+ def temperature (self ):
119
+ """The temperature of the thermistor in Celsius"""
120
+ steinhart = self .resistance / self .nominal_resistance # (R/Ro)
117
121
steinhart = math .log (steinhart ) # ln(R/Ro)
118
122
steinhart /= self .b_coefficient # 1/B * ln(R/Ro)
119
123
steinhart += 1.0 / (self .nominal_temperature + 273.15 ) # + (1/To)
You can’t perform that action at this time.
0 commit comments