thermistor: Avoid divide by zero error if min_temp=-273.15

Reported by @TheGuv.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-01-04 12:30:20 -05:00
parent 277a8185e1
commit 7fe14f05e6
1 changed files with 2 additions and 0 deletions

View File

@ -75,6 +75,8 @@ class Thermistor:
temp = 1.0/inv_t + KELVIN_TO_CELCIUS
self.temperature_callback(read_time + SAMPLE_COUNT * SAMPLE_TIME, temp)
def calc_adc(self, temp):
if temp <= KELVIN_TO_CELCIUS:
return 1.
inv_t = 1. / (temp - KELVIN_TO_CELCIUS)
if self.c3:
# Solve for ln_r using Cardano's formula