Hello,
Is this viable as a conversion method from ADC reading to NTC thermistor temperature?
I'm using the Beta factor to convert it.
float rawTempToActual(int raw) {
adcVoltage = rawTemp * (3.3/4096);
thermistorResistance = -((adcVoltage * 10000) / (adcVoltage - 3.3)); //for 10k R1 in series with thermistor and connected to 3.3V reference voltage
actualTemp = 1 / ((log(thermistorResistance / 10000) / 3435) + (1 / 298.15)); //for a thermistor with Beta 3435K, 10kohm @ 25°C
return actualTemp;
}
Now, I haven't actually tested this, but all of the calculations are based off of known and proven equations. Made for a thermistor with Beta of 3435K, 10kohm @ 25°C, reference voltage of 3.3V, 10k resistor connected between 3.3V and the thermistor, and a 12bit ADC.
Furthermore you could have a look at my multimap library, that approximates conversions with interpolation. Could be more performant (and depending on number of points less accurate but accurate enough).
The - in front is required for the calculation. If you look at the divisor in the equation, it comes out negative, which would mean the entire equation would come out negative in the end. The intended output is Kelvin, so that checks out, I guess.
Interesting, thank you! I'll take a look. The performance isn't really that important, I mean, if the calculation takes 10ms, that's okay. Its not a time or performance critical application.
Looks like you have a 12-bit ADC, and the ADC input value with a thermistor will be only a portion of that, so there is a limited number of possible temperatures produced by the equation. If the is no other need for floating point numbers, a lookup table might take less memory than the code needed for floating point calculations.
I'm using an STM32F411CEU6 Blackpill board, so my current code only takes a few % of the flash and RAM. And there's a whole lot more code that just this funtion.