public class Thermistor extends AnalogComponent
To do this, we use a an ADC (Anolog to Digital Converter) to measure the voltage value around the thermistor. We then calculate the value of the thermistor resistance, using the voltage divider in place with a resistor in serie with the thermistor.
We can then convert the resistance value with the Steinhart-Hart equation.
1/T = a + b ln(R) + c ln(R)^3As we don't know all the requested parameters (A, B and C), we will use the B-parameter equation, which is essentially the Steinhart-Hart equation with
a = (1/T0) - (1/B) ln(R0) b = 1/B c = 0
Note: with our observations, we can observe an error of about 1.4% in temperature measurements (using the Kelvin scale). A temperature of 24°C should correspond to a real temperature of 20°C. Different factors can be at the origin of this problem. It's important to keep this in mind, and use a thermistor for appropriate use. As an example, a thermistor can be used as a trigger to track a temperature exceeding a fixed threshold: alert when the tap water is too hot. It is less appropriate to precisely define the room temperature.
Formulas from: https://en.wikipedia.org/wiki/Thermistor
Modifier and Type | Field and Description |
---|---|
static double |
K_TO_C
Temperature in °C is temperature in K - K_TO_C.
|
static double |
T0
T0 coefficient from the B-parameter equalition, in K.
|
adc
Constructor and Description |
---|
Thermistor(ADC adc,
ADCChannel thermistorChannel,
double serieResistor,
double r0,
double b)
Constructor for a thermistor using a specific ADC instance, a specific channel on this ADC,
and specific parameters regarding the thermistor characteristics.
|
Modifier and Type | Method and Description |
---|---|
double |
getTemperature()
Return the measured temperature, in °C.
|
getADC, getType
public static final double T0
298.15K = 25°C.
public static final double K_TO_C
public Thermistor(ADC adc, ADCChannel thermistorChannel, double serieResistor, double r0, double b)
adc
- the ADC to use to decode analog voltage values around the thermistor.thermistorChannel
- the channel used on the ADC to read voltage values around the thermistor.serieResistor
- the value of the resistance placed in serie with the thermistor.r0
- the resistance of the thermistor, at 25 degrees Celsius (cfr thermistor datasheet).b
- the B-parameter equation coefficient (cfr thermistor datasheet).public double getTemperature()
Keep in mind the note presented in this class header: Thermistor