20 lines
454 B
C++
20 lines
454 B
C++
#include "thermistor.hpp"
|
|
|
|
#include <math.h>
|
|
|
|
double Thermistor::getResistance(double adcSample)
|
|
{
|
|
return SERIES_RESISTOR * adcSample / (1023 - adcSample);
|
|
}
|
|
|
|
double Thermistor::getTemperature(double resistance)
|
|
{
|
|
double steinhart = resistance / THERMISTOR_NOMINAL;
|
|
steinhart = log(steinhart);
|
|
steinhart /= BETA_COEFFICIENT;
|
|
steinhart += 1.0 / (NOMINAL_TEMPERATURE + 273.15);
|
|
steinhart = 1.0 / steinhart;
|
|
steinhart -= 273.15;
|
|
return steinhart;
|
|
}
|