createTemperatureLookup.py: deal with precision limitation on R0.
Inserting a dummy value is better than risking an exception with failure to write a thermistor table at all. Happens when for one of the usual thermistors accidently a nominal resistance of 1000k instead of 100k is used.
This commit is contained in:
parent
48433a6254
commit
2d191768ca
|
|
@ -62,7 +62,10 @@ class Thermistor:
|
|||
def temp(self,adc):
|
||||
"Convert ADC reading into a temperature in Celcius"
|
||||
v = adc * self.vadc / 1024 # convert the 10 bit ADC value to a voltage
|
||||
if (self.vs - v): # can be zero due to accuracy limitations
|
||||
r = self.rs * v / (self.vs - v) # resistance of thermistor
|
||||
else:
|
||||
r = self.r0 * 10 # dummy value
|
||||
try:
|
||||
return (self.beta / log(r / self.k)) - 273.15 # temperature
|
||||
except:
|
||||
|
|
|
|||
Loading…
Reference in New Issue