NTC Thermistor Integration

Hi folks.

Well I'm back with this thermoprobe project. I've gained some insight and I'm pretty close, but need some help. Let me reset the stage here and describe what I'm trying to do, where I am at, and what the challenge is.

The Project

I want to build a multiple-probe BBQ system that measures as many thermoprobes as I can. When I get the data, I can send it wirelessly or keep the data...I'll deal with that once I get this going. The thermoprobes are actually negative slope thermistors. Resistance decreases as temperature increases. I loosely calibrated a probe yesterday and plotted it. It turns out it is a logarithmic curve with the following trend line:

Tp = -32.228ln(Rp) + 323.17

Tp = probe temperature in °C
Rp = probe measured resistance in Ohms

I've measured resistance from 15,500 Ohms at 15°C, down to 1,500 Ohms at 89.9°C. So essentially, if I can measure the resistance as an analog input on the Arduino, I can import math.h and use the log function and find out the temperature. Bingo.

The Problem(s)

I'm not sure how to hook up the probe (two terminals on the probe) so that I can do this. Basically it's a potentiometer, but with only two pins, not three. It functions as a resistor. Do I hook it up to 5V and A0? Not too sure about this circuitry.

Second issue is the association with the resistance measure to the map. I guess I have to calculate the resistance based upon the measured input of the voltage through the probe. But how do I calculate that? Let's say it's 500/1024 = 48.8% potential of the 5V feed voltage). R = I/V doesn't help me here, and not sure what to use.

Any insight appreciated.

Cheers!

you have to make a voltage divider with 2 resistors.

GND -----[ NTC ] ------x-------[ 10K ]----- +5V

The x connects to the analog pin of the Arduino.

if NTC = 1500 ohm ==> 0.652Volt => analogRead => 130
if NTC = 15500 ohm ==> 3.039Volt => analogRead => 608

If you change the 10K for 4K7 or another value the numbers will change of course..

Hop this helps.

Hi Rob. Ya I bought up a voltage divider image right after I posted. I will try this afternoon and report.

Cheers

OK I have it set up and the R2 is 3500 Ohms. sensorValue comes back at 405. 405/1024 * 5V = 1.98V. My multimeter is reading 4.8V. No clue what is happening, other than the calculations are wrong. What should I try?

UPDATE: Sorry, was reading the wrong things. I'll come back to this later.

Cheers

the multimeter should also read between GND and X.

OK this has me stumped. I'm getting some things right and some things wrong, so I'll start at the top and describe as much as I can.

I've replaced the thermistor with a known resistor. Its value is 2150 Ohms.

Rtop = 2150 Ohms (measured)
Rbottom = 350 Ohms (measured)
Vin = 5V

sensorValue measured at ~405, which corresponds to 5V * 405/1024 = 1.98V. Calculated.

Vout = Vin * Rtop/(Rtop + Rbottom)

Rbottom = (Vin * Rtop - Vout * Rbottom)/Vout

Paper math says it's 533.84 Ohms. But it isn't. It's 2150 Ohms measured and labelled.

The math runs up, but it's not what the truth is. Not sure how to proceed. I don't think the circuit is designed wrong, but it's possible, I guess.

I'm stumped.

total R = 2500 ohm so there is running a current of 5/2500 = 0.2 mA

Voltage over Rbottom = 0.2mA * 350 = 0.7Volt
Voltage over Rtop = 0.2mA * 2150 = 4.3 Volt

this should be verifiable with your multimeter.

so it is strange you measure 1.98V ?

can you post your sketch?

Hi there. I'm going to rebuild it. I'm not measuring anything close to the Rtop. How can I provide a sketch? I forget the tool.

Cheers

sketch is the name arduinese use for the source code :wink:

Heh I knew that. I was thinking you wanted a physical layout. It's been some time since I've been at this stuff.

OK, here is the rebuild. Same results. Measured Vout is 1.96V approx.

#include <math.h>

void setup() {
  Serial.begin(9600);
}

long counter = 1;
int delaySeconds = 5;
int masterDelay = 1000 * delaySeconds;
// R1 = Thermistor, reading of fraction in a 0 to 1024 scale of 5V input
float Rbottom = 350;
float Vin = 5;                            // input voltage
  
void loop() {
  float sensorValue = analogRead(A0);                    // read sensor
  float Vout = (sensorValue/1024) * Vin;
  float Rtop = (((Vin * Rbottom) - (Vout * Rbottom)) / Vout);
  float myTemp = (-32.228 * log(Rtop) + 323.17);          // thermistor trendline
  
  Serial.print("SensorValue: ");
  Serial.print(sensorValue);
  
  Serial.print("/Vout: ");
  Serial.print(Vout);
  
    
  Serial.print("/Rtop: ");
  Serial.print(Rtop);
    
  Serial.println("");
  delay(masterDelay);
  if(counter == 100) { counter = 1;  } else { counter++; } 
}

Result:

SensorValue: 405.00/Vout: 1.98/Rtop: 534.94

Is Rtop the NTC?

if so what voltage do you get if you swap the two resistors?

Rbottom is the variable resistor (NTC), replaced by the test R2, which is 2150 Ohms.

When flipped, it's basically the other side of the full circuit potential:

SensorValue: 617.00/Vout: 3.01/Rtop: 230.88

Here's a verbal description of my circuit:

5V --- Rtop (350 Ohms) ----- X ------ Rbottom (2150 Ohms) ----- Ground

X has a lead to A0
I measure voltage from X to another Ground, so the potential over Rbottom

(I have no clue ...)

5V --- Rtop (350 Ohms) ----- X ------ Rbottom (2150 Ohms) ----- Ground

what does the multimeter measure (volts) between GND and X when X is connected to the Arduino?

With the original setup (5V --- Rtop (350 Ohms) ----- X ------ Rbottom (2150 Ohms) ----- Ground), 1.96V. X is on a breadboard where I insert a lead to measure voltage to the Arduino ground. Should I send a picture?

So the multimeter gives the same voltage as the Arduino, at least that is consistent.

But seen the values of the resistors there should be a ration of 1:6 somehing like 0.7V - 4.3V

2 new measurements:

  1. Can you measure the current low through the two resistors ?
    expected value 5V / 2500 ohm = 2 mA

  2. Can you please measure the resistors again. I know it sounds stupid but still ..

you can always send a picture ..

OK, it turns out that Rtop was indeed wrong. 3500 instead of 350. I apologize for that. Also turns out that Rbottom was off reported resistance by the 1% it said it could have, so I replaced it. Now, here is the following to report:

#include <math.h>

void setup() {
  Serial.begin(9600);
}

int delaySeconds = 5;
int masterDelay = 1000 * delaySeconds;
float Rtop = 3500;
float Vin = 5;                            // input voltage
  
void loop() {
  float sensorValue = analogRead(A0);                    // read sensor
  float Vout = (sensorValue/1024) * Vin;
  float Rbottom = -Rtop + Rtop * (Vin/Vout);
  // float myTemp = (-32.228 * log(Rtop) + 323.17);          // thermistor trendline
  float VRatio = Vout/Vin;
  float RRatio = Rtop/(Rtop + Rbottom);
  
  Serial.print("SensorValue: ");
  Serial.print(sensorValue);
  
  Serial.print("/Vout: ");
  Serial.print(Vout);

  Serial.print("/Rbottom: ");
  Serial.print(Rbottom);
  
  Serial.print("/VoltRatio: ");
  Serial.print(VRatio);
  
  Serial.print("/RRatio: ");
  Serial.print(RRatio);  
   
  
  Serial.println("");
  delay(masterDelay);
}

Result: SensorValue: 403.00/Vout: 1.97/Rbottom: 5393.30/VoltRatio: 0.39/RRatio: 0.39

So the ratios are good. The measured Voltage is good. The Rbottom is wrong though. It's measured at 2150, reported through the math at 5393.30, which is 2.5x what it should be.

Didn't take any pictures as it is taking shape now.

Just as an aside, I replaced Rbottom with a 51 Ohm resistor, and I get this: SensorValue: 11.00/Vout: 0.05/Rbottom: 322318.18/VoltRatio: 0.01/ResRatio: 0.01

Vout is right. ResRatios don't mean anything because it relies on Rbottom.

I think we need to focus on Rbottom calculations.

Think there is a flaw in the code as the ratio between 3500 and 5393 is almost exactly the ratio between 2150 and 3500

the current flowing through the system is +> A = (Vin-Vout) / R.top
this current also flows through Rbottom resulting in Vout => A * Rbottom = Vout
or Rbottom = Vout / A;

combining these ==> Rbottom = Vout / ( (Vin-Vout) / Rtop) = Vout * Rtop / (Vin-Vout);

==> float Rbottom = Vout * Rtop / (Vin - Vout);

testing with the values: 1.97 * 3500 / ( 5 - 1.97) = 2275 just 1% above the 2150

OK, I worked it out and that formula is right. I just tried:

Rtop = 3280, Rbottom (test) = 2150
Vin = 5V, SensorValue = 357

Rbottom = (1.72 * 3280)/(5 - 1.74) = 1750 Ohms, which is wrong.

OK, I'm not sure I'm covering all aspects. I'm using 2 multimeters here, neither of which can read Amperage.