Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.

Commit

Permalink
createTemperatureLookup.py: deal with precision limitation on R0.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Traumflug committed Apr 21, 2015
1 parent 48433a6 commit 2d19176
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion createTemperatureLookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def __init__(self, r0, t0, beta, r1, r2,vcc,vadc):
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
r = self.rs * v / (self.vs - v) # resistance of thermistor
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:
Expand Down

0 comments on commit 2d19176

Please sign in to comment.