28 lines
597 B
C++
28 lines
597 B
C++
|
#pragma once
|
||
|
|
||
|
#include <stdint.h>
|
||
|
|
||
|
class Thermistor {
|
||
|
public:
|
||
|
template <typename Adc>
|
||
|
static double sampleAdc(Adc &adcPin, uint16_t numSamples = 100)
|
||
|
{
|
||
|
double samples = 0;
|
||
|
|
||
|
for (uint16_t i = 0; i < numSamples; ++i)
|
||
|
samples += adcPin.read();
|
||
|
|
||
|
return samples / numSamples;
|
||
|
}
|
||
|
|
||
|
static double getResistance(double adcSample);
|
||
|
|
||
|
static double getTemperature(double resistance);
|
||
|
|
||
|
private:
|
||
|
static constexpr auto SERIES_RESISTOR = 9951;
|
||
|
static constexpr auto THERMISTOR_NOMINAL = 9270;
|
||
|
static constexpr auto BETA_COEFFICIENT = 3212;
|
||
|
static constexpr auto NOMINAL_TEMPERATURE = 25;
|
||
|
};
|