Analog Input (Thermistor) example with imp002

I am following the sample project @
with the imp002 instead of imp001+april board.

Using the following configuration…

can I use the same GetTemp function code ?

function GetTemp_F() {
local Vin = hardware.voltage();

local Vout = Vin * / 65535.0;
local R_Therm = (R2*Vin / Vout) - R2;

local ln_therm = math.log(10000.0 / R_Therm);
local temp_K = (t0_therm * b_therm) / (b_therm - t0_therm*ln_therm);

local temp_C = temp_K - 273.15;
local temp_F = temp_C * 9.0 / 5.0 + 32.0;

return temp_F;

Is the hardware.voltage() read correctly ?

Thank You!

Yes hardware.voltage() should return the right value for you. What are you seeing as a result from the code?

I need Celsius, so my code is…

function GetTemp_C() { local Vin = hardware.voltage(); local Vout = Vin * / 65535.0; local R_Therm = (R2 * Vin / Vout) - R2; local ln_therm = math.log(R2 / R_Therm); local temp_C = (t0_therm * b_therm) / (b_therm - t0_therm * ln_therm) - 273.15; return temp_C; }

I read good values, near to the real temp. I just have to correct the formula, setting the appropriate b_therm and acting on R2 value.

R2 is 10K with 1% tolerance
NTC is 10K with 5% tolerance

I was asking you to validate schema :slight_smile:

Thank You!

I can’t really validate your formula… have you got the right curve values in there? Because, at 25C, the NTCs are all at the same point regardless of curve you don’t tend to see the difference in curves until you move away from 25C :slight_smile: