Help with accurate temperature measurement with thermistor

Hey guys,
I have a small problem. I am making a heater that is controlled by a 100K NTC 3950 thermistor and it always measures well up to 200C, but when it exceeds this temperature it starts to measure strangely, for example it gets stuck at 215C and after a few seconds jumps to 260C and I need my heater to turn off at 220C and go fluently and stably to this temperature. I think the problem is somewhere in the code, but I'm not sure.

Thank you in advance for your reply. (and sorry for my English)

code:

#include <Wire.h>
#include <SPI.h><br>#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

//heater

int heater_out = 2;

float target = 220;

int thermistorPin = A0;
int Vo;  // Holds the ADC Value
float R2, tKelvin, Tc;
const float Beta = 3950;
const float roomTemp = 298.15;  // room temperature in Kelvin
const float Ro = 10000.0;       // Resistance of the thermistor at roomTemp
const float R1 = 10000.0;       // Resistnce of the known resistor


void setup() {

  //display
  Serial.begin(9600);
  pinMode(0, INPUT);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);


  //heater


  pinMode(heater_out, OUTPUT);
}


void loop() {

  Vo = analogRead(thermistorPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);  // Resistance of the Thermistor
  tKelvin = (Beta * roomTemp) / (Beta + (roomTemp * log(R2 / Ro)));
  Tc = tKelvin - 273.15;

  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.println(Tc);
  display.println(" C"); 
     
  display.display();

  delay(200);


  //heater

  if (Tc >= target) {
    digitalWrite(heater_out, HIGH);
  } else {
    //Turn ON heater_out
    digitalWrite(heater_out, LOW);
  }
}

Are you sure that the thermistor and probe construction is rated for such relatively high temperatures? Please post a link to the thermistor data sheet.

Most people use thermocouples for temperatures well over 100 degrees C.

If the thermistor is 100K nominal, what value is the other resistor in the voltage divider, and why does the code claim 10K?

Where did you get that beta value?

On the e-shop where I bought it, unfortunately it is not written anywhere, only on google (what I was searching, its max temperature should be 300C), but the e-shop focuses on 3D printers, so it should be able to measure such high temperatures ( neither a datasheet, so at least I attach a similar one: datasheet (temperature)).
this is what my thermistor looks like:

there is also a 100K resistor. Because when i put 100K there, too high temperature was printed (around 40C as room temperature).

From the name of the thermistor, in most datasheets it was written that it is beta.

And thanks for the reply.

Here is more, but it's also a little bit different thermistor: datasheet

Without a data sheet, and a trusted supplier, it is a mistake to assume that the thermistor and probe assembly is rated for those temperatures.

The thermistor resistance can be measured at various temperatures, and used to calibrate the beta value together with this calculator: SRS Thermistor Calculator

Good luck with your project.

Look at the picture. Is that rubber mounting or heat shrink tubing. It is something that has been shrunk, likely by heat. Doesn't look like 300C material.

When you fix your problem, this scale factor is incorrect. Use

  R2 = R1 * (1024.0 / Vo - 1.0);  // Resistance of the Thermistor

Also you don't need the cast, the expression is evaluated left to right, and Vo is automatically up cast.

1 Like

Hi,

What does your thermistor measure with a DMM at about room temperature?


100,000 not 10,000!!!!

Can we please have a circuit diagram?
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.

Can you please post some images so we can see your component layout?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

1 Like

Ok, next time I buy something I will only buy from quality e-shops and thanks for your help.

The website says it's teflon tubing, but it probably shrunk by heat. But the rubber hasn't melted yet, so it's probably good.

I don't have a dmm, but I did some provisional and there I compare the 100K resistor with my thermistor and around 19C I measured 1188.03 ohms.

I know, but as I said, when I put 100,000 in there, it measured the wrong temperature.

schematic:

1 Like
  pinMode(0, INPUT);

This will set digital pin 0 to input, not analog pin A0. Also, there is no need to set the analog pin to input mode when using for analog input.

Since you are switching the heater off at 220, I would suspect a glitch in the power is possibly resetting the arduino. Depending on what you are heating and the power of the heater, overshooting to 260C is a definite possibility, so that reading may be correct.

If the probe is intended for measuring the extruder temperature of a 3D printer then the sensing end should be easily capable of withstanding the temperatures.

1 Like

Hi,

I'm not sure of your methodology.

I would say you do not have a 100K NTC, but a 10K or a 1K thermistor.

I would recommend you purchase an in expensive DMM.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

I heat an aluminum heatblock and my heater element has 40W so I think it should have heated up fine, and what do you mean glitch in the power?

Voltage drops/spikes on Vcc when the heater is triggered. They can lead to processor resets or malfunction.

Me too, how much ohms should it be approximately?

Aaah thanks. If that is the problem, is it possible to fix it, eventually how?

If the power supply can't supply enough current for the project, the voltage will drop when it is overloaded. The solution is to use a power supply that can provide the required current.

I was speculating that the processor was resetting when you turned the heating element OFF, since you said the temperature reading gets stuck around 215C then jumps to 260C a few seconds later. If the OLED does not get an actual reset signal, it will retain the previous image while the processor is resetting, which takes a few seconds because of the delay caused by the bootloader.

1 Like

This is just a wild guess and I haven't studied the formula but you might be in a range where a very small-normal change/variation in the raw reading makes a huge change in the logarithmic calculation...

ADC readings are quantized so they are never "perfectly smooth" and under some conditions you simply don't have enough resolution,

The output of a volage divider is also not linear with changes in resistance (which is why you need a log calculation). And the output gets "strange" when the thermistor changes and the two resistors are no longer similar.

You can also hit the analog limits of the ADC but that won't cause noise/instability in the readings.

P.S.
Since the thermistor is "calibrated" at room temperature you can probably get better results with a different series resistor, adjusting the formula accordingly.

...I don't know how to change the formula but it shouldn't be too difficult.