6 #ifndef __SENSORS_NTC_h__
7 #define __SENSORS_NTC_h__
24 template <u
int8_t SENSEPIN,u
int32_t R0=10000,u
int16_t B=3435,u
int8_t ACTIVATEPIN=0,
int8_t T0=25,u
int8_t OVERSAMPLING=0>
26 const int32_t _t0Abs = T0 * 10 + 2732;
27 const int32_t _max_ref = (1 << (10 + OVERSAMPLING)) - 10 - OVERSAMPLING;
33 pinMode(SENSEPIN, INPUT);
36 bool measure (__attribute__((unused))
bool async=
false) {
40 pinMode(ACTIVATEPIN, OUTPUT);
41 digitalWrite(ACTIVATEPIN, HIGH);
44 for (uint16_t i = 0; i < 1 << (OVERSAMPLING * 2); i++) {
45 vo += analogRead(SENSEPIN);
49 digitalWrite(ACTIVATEPIN, LOW);
53 vo = vo >> OVERSAMPLING;
58 float rNtc = vo / (float)(_max_ref - vo);
59 _temperature = 10 * B * _t0Abs / (10 * B + (int16_t)(log(rNtc) * _t0Abs)) - 2732;