nrfcxx
0.1.0
C++-17 Framework for Nordic nRF5 Devices
|
Type holding Steinhart-Hart coefficients and extreme values. More...
#include <nrfcxx/sensor/adc.hpp>
Public Member Functions | |
constexpr | SteinhartHart (float a=1.19438315714902408e-03, float b=2.19852114398042317e-04, float c=1.72427510143621963e-07, uint16_t open_adc16=2281, uint16_t short_adc16=65133) |
Store the coefficients and reference values. More... | |
int | temperature_cK (unsigned int therm_Ohm) const |
Calculate the temperature corresponding to a measured thermistor resistance. More... | |
Data Fields | |
const float | a |
Coefficient of ln(R)^0. | |
const float | b |
Coefficient of ln(R)^1. | |
const float | c |
Coefficient of ln(R)^3. | |
const uint16_t | open_adc16 |
16-bit ADC upper threshold for open thermistor. More... | |
const uint16_t | short_adc16 |
16-bit ADC lower threshold for shorted thermistor. More... | |
Type holding Steinhart-Hart coefficients and extreme values.
These coefficients are used to calculate the temperature given the measured resistance of an NTC thermistor. Steinhart-Hart is significantly more accurate across a wide range of temperatures than linear interpolation, and generally requires less space than table lookup.
The class also provides calculations for a thermistor installation where Vcc leads to a voltage divider where the top resistor is the thermistor, the bottom resistor is #ref_Ohm, and the ADC is measuring the divided voltage. In this configuration an open thermistor allows no current flow (divided voltage is zero), and a shorted one allows maximum flow (divided voltage is Vcc).
For generality it is assumed a 16-bit ADC is used.
|
inlineconstexpr |
Store the coefficients and reference values.
Default values correspond to the values for a full-scale (-40 Cel to 200 Cel) measurement with the Adafruit #372 NTC thermistor.
a | the coefficient scaling ln(R)^0 in the Steinhart-Hart equation. |
b | the coefficient scaling ln(R)^1 in the Steinhart-Hart equation. |
c | the coefficient scaling ln(R)^3 in the Steinhart-Hart equation. |
open_adc16 | the value used to initialize open_adc16. |
short_adc16 | the value used to initialize short_adc16. |
ref_Ohm | the resistance of the top resistor in the measured voltage divider. |
int nrfcxx::sensor::adc::SteinhartHart::temperature_cK | ( | unsigned int | therm_Ohm | ) | const |
Calculate the temperature corresponding to a measured thermistor resistance.
therm_Ohm | the measured resistance of the thermistor, in Ohms. |
const uint16_t nrfcxx::sensor::adc::SteinhartHart::open_adc16 |
16-bit ADC upper threshold for open thermistor.
An open thermistor has an infinite resistance corresponding to an extremely low temperature.
If the measured 16-bit ADC value is at or below this value assume the thermistor is open.
const uint16_t nrfcxx::sensor::adc::SteinhartHart::short_adc16 |
16-bit ADC lower threshold for shorted thermistor.
A shorted thermistor has a tiny resistance corresponding to an extremely high temperature.
If the measured 16-bit ADC value is at or above this value assume the thermistor is shorted.