Humidistat
Arduino firmware for a humidistat (humidity controller)
Loading...
Searching...
No Matches
ThermistorReader.cpp
Go to the documentation of this file.
1#include <Arduino.h>
2#include "ThermistorReader.h"
3
4ThermistorReader::ThermistorReader(uint8_t pin) : pin(pin) {}
5
7 // Read temperature using reference 3.3V on A5 pin
8 double V_NTC = analogRead(pin) / static_cast<double>(analogRead(ref_pin));
9 return R_series * (1 / V_NTC - 1);
10}
11
13 return B / log(getThermistorResistance() / r_inf) - 273;
14}
const double r_inf
Thermistor's value of R_inf in the thermistor equation (Ohm)
double getThermistorResistance() const
Calculate the resistance of the thermistor in the voltage divider.
const double B
Thermistor's value of B in the thermistor equation (K)
double readTemp() const
Get the temperature of the thermistor.
const uint8_t pin
NTC pin number.
const double R_series
Resistance of R2 in voltage divider (Ohm)
const uint8_t ref_pin
Reference (high) voltage pin number.
ThermistorReader(uint8_t pin)
Constructor.