KTY82-210 temperature sensor

Hi all,

I'd like to ask your help to solve a problem with a sensor.

I'm trying to read a temperature from the sensor KTY82-210, I get several problems and can't understand what I'm missing.

I tried to connect it in this way:
Scheme and tried different resistor. I just get weird numbers when heating.

I tried different codes like:
taken from HERE

 float kty(unsigned int port) {
         float temp              = 82;
         ADCSRA = 0x00;
         ADCSRA = (1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);
         ADMUX = 0x00;
         ADMUX = (1<<REFS0);
         ADMUX |= port;   

         for (int i=0;i<=64;i++)
         {
                 ADCSRA|=(1<<ADSC);
                 while (ADCSRA & (1<<ADSC));
                 temp += (ADCL + ADCH*256);
         }

         temp /= 101;
         temp -= 156;
       return (temp);
 }

 float read_temp = kty(0);
 print(read_temp);

or:

double Thermistor(int RawADC) {
 double Temp;
 Temp = log(1000.0/(1024.0/RawADC-1)); // for pull-up configuration
         
// Temp =  log(10000.0*((1024.0/RawADC-1))); 
 Temp = 1 / (0.001732725 + (0.000208681 + (0.0000000429398 * Temp * Temp ))* Temp );
 //Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
 Temp = Temp - 273.15;            // Convert Kelvin to Celcius
 //Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
 return Temp;
}

I can't find any help with this sensor online but only with the 81 series.

Can someone please help me out?

Does anyone ever used this sensor?

thank you

Sensor datasheet:KTY82-210 Datasheet

It (KTY82-210) is a PTC device; at room temperature, its resistance is about 2000 ohm at 1 mA sense current. So, choose a resistor of about 3000 ohm (2000x1 mA + 3000 x 1 mA = 5V) at the 5V side and try.

It is possible to create simple codes for its operation:
1. Place the sensor network in ice water and record: A(4 degC = TA, DVMredaingA = VA).

2. Place a thermometer and the sensor in a beaker with water. Boil the water until it starts evaporating. Record: B(therometerreading=TB, DVMReadingB=VB).

3. Find the equation for the unknown temperature T as:

(TB - TA)/(VB-VA) = (TB - T)/(VB - V)    //V is DVM reading corresponding to temperate T degC.

==> T = kV + c    //k and c are computed known constatnts from the above realtion.
==> T = k*(5/1023)*analogRead(A0) + c //(1023/5)*V = analogRead(A0) with Vref= 5V

4. Write codes for the equation of Step-3.

GolamMostafa:
...its resistance is about 2000 ohm at 1 mA sense current. So, choose a resistor of about 3000 ohm...

Why?

You normally choose a pull up resistor value in the middle of the temp range of interrest, to maximise A/D resolution.
That could mean a 2k resistor if you want to measure ~25C room temps,
or a 3k3 resistor if you want to measure boiling water.
(see sensor datasheet)

Note that this sensor has a poor resolution (>= 0.5C steps) when used with a 10-bit A/D.
Leo..

Wawa:
Why?

I also consulted data sheets where I found the sensor resistance is about 2000 ohm at room temperature and at 1 mA sense current. So at 5V bias voltage, the value of pull-up becomes as: 3000 ohm (5V = 2000 1 mA + 30001mA). It is a rough estimation to make a functional check of the sensor.

@ GolamMostafa
I understood that you used 3k to get that 1mA, but I don't understand the reasoning behind it.
Only that self-heating errors are getting higher above ~2mA sensor current.

I assume you understand that in a ratiometric setup like this you get the highest A/D resolution if sensor and pull up are about the same value.
A poor two A/D values per degree C at best when used with a 10-bit A/D.
Leo..

Thanks everyone for your reply, I did some trials and decided to use a 3.3kohm resistor. I could not understand nor build a working equation so i used a lookup table which is very good until 100 °C (i could not check above that temperature in that moment. I compared the data with a DS18 temperature sensor so i'm quite sure the measures are good. Now i'd like to go further and understand why my equations didn't work with this thermistor, and if someone is as curious as me we can try to figure it out.

I used this code: (it contains a lot of trials and comments, don't care about those)

#include <OneWire.h>
#include "lookupTEMP.h"

// OneWire DS18S20, DS18B20, DS1822 Temperature Example
//
// http://www.pjrc.com/teensy/td_libs_OneWire.html
//
// The DallasTemperature library can do all this work for you!
// https://github.com/milesburton/Arduino-Temperature-Control-Library

OneWire  ds(2);  // on pin 10 (a 4.7K resistor is necessary)
/*
double sonda0;

//misura sonda NTC
double Thermistor(int RawADC) {
 double Temp;
 Temp = log(8800.0/(1024.0/RawADC-1)); // for pull-up configuration
         
// Temp =  log(10000.0*((1024.0/RawADC-1))); 
 Temp = 1 / (0.001732725 + (0.000208681 + (0.0000000429398 * Temp * Temp ))* Temp );
 //Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
 Temp = Temp - 273.15;            // Convert Kelvin to Celcius
 //Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
 return Temp;
}
*/

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

void loop(void) {


  
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;
  int adcIN;
  byte c ;  //suppporto ciclo for
  
  if ( !ds.search(addr)) {
    //Serial.println("No more addresses.");
    //Serial.println();
    ds.reset_search();
    //delay(250);
    return;
  }
  
  //Serial.print("ROM =");
  for( i = 0; i < 8; i++) {
    //Serial.write(' ');
    //Serial.print(addr[i], HEX);
  }

  if (OneWire::crc8(addr, 7) != addr[7]) {
      //Serial.println("CRC is not valid!");
      return;
  }
 // Serial.println();
 
  // the first ROM byte indicates which chip
  switch (addr[0]) {
    case 0x10:
      //Serial.println("  Chip = DS18S20");  // or old DS1820
      type_s = 1;
      break;
    case 0x28:
     // Serial.println("  Chip = DS18B20");
      type_s = 0;
      break;
    case 0x22:
      //Serial.println("  Chip = DS1822");
      type_s = 0;
      break;
    default:
      //Serial.println("Device is not a DS18x20 family device.");
      return;
  } 

  ds.reset();
  ds.select(addr);
  ds.write(0x44, 1);        // start conversion, with parasite power on at the end
  
  //delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.
  
  present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE);         // Read Scratchpad

  //Serial.print("  Data = ");
  //Serial.print(present, HEX);
  //Serial.print(" ");
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
    //Serial.print(data[i], HEX);
    //Serial.print(" ");
  }
  //Serial.print(" CRC=");
  //Serial.print(OneWire::crc8(data, 8), HEX);
  //Serial.println();

  // Convert the data to actual temperature
  // because the result is a 16 bit signed integer, it should
  // be stored to an "int16_t" type, which is always 16 bits
  // even when compiled on a 32 bit processor.
  int16_t raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) {
      // "count remain" gives full 12 bit resolution
      raw = (raw & 0xFFF0) + 12 - data[6];
    }
  } else {
    byte cfg = (data[4] & 0x60);
    // at lower res, the low bits are undefined, so let's zero them
    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
    //// default is 12 bit resolution, 750 ms conversion time
  }
  celsius = (float)raw / 16.0;
  //fahrenheit = celsius * 1.8 + 32.0;
  /*Serial.print("  Temperature = ");
  Serial.print(celsius);
  Serial.print(" Celsius, ");
  Serial.print(fahrenheit);
  Serial.println(" Fahrenheit");
*/
//sonda0 = double(Thermistor(analogRead(A0)));
  //Serial.print("S0 - DS ");
  //Serial.print(sonda0);
  Serial.print("D: ");
  Serial.print(celsius);

  adcIN=analogRead(0);

  for(c=0;lookUp[c]<adcIN;c++);

  Serial.print("  T: ");
  Serial.print(c-10); 
  
  Serial.print(" KT: ");
  Serial.println(adcIN);
  

delay(500);
}

with this lookup table:

int lookUp[]= {
//-10
319,321,323,325,327,329,331,333,335,337,
//0
339,341,343,344,346,348,350,352,354,356,
//10
358,360,362,364,365,367,369,371,373,375,
//20
377,379,381,383,384,
//25
386,388,390,392,394,
//30
396,398,400,402,403,405,407,409,411,413,
//40
415,417,419,421,422,424,426,428,430,431,
//50
433,435,436,438,440,442,443,445,447,449,
//60
451,453,454,456,458,460,461,463,465,467,
//70
469,470,472,474,475,477,479,481,482,484,
//80
486,487,489,491,492,494,496,497,499,501,
//90
503,505,506,508,510,511,513,515,516,518,
//100
519,521,522,524,526,528,529,531,333,534,
//110
535,537,538,540,541,543,544,545,547,548,
//120
549,550,551,552,554,555,557,558,560,561,
//130
562,563,564,565,566,567,568,569,570,570,
//140
571,572,573,573,574,575,575,576,577,577,
//150
578};

hope this might help someone else...

As I was saying, I'd like to be able doing an equation which simplyfies the code like I always did with other thermistor.

I used a little software to find thermistor coefficent A B C and they results to me:

R1 2080 T1 30
R2 2980 T2 80
R3 4166 T3 140

Coeff.
A = 17.32725887 e-3
B = -20.86815698 e-4
C = 42.93982203 e-7

R 25°C 1993.28 ohm
beta -769.86 K

If someone can explain me what's my mistake... I can't figure it out

I usually use this code just changing A B C coefficents...

double Thermistor(int RawADC) {
 double Temp;
 Temp = log(1000.0/(1024.0/RawADC-1)); // for pull-up configuration
         
// Temp =  log(10000.0*((1024.0/RawADC-1)));
 Temp = 1 / (0.001732725 + (0.000208681 + (0.0000000429398 * Temp * Temp ))* Temp );
 //Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
 Temp = Temp - 273.15;            // Convert Kelvin to Celcius
 //Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
 return Temp;
}