Arduino and KTY81-210

You have a lot of possibilities to measure the temperature with an arduino. One simple solution is the usage of a KTY81 silicon temperature sensors.
Arduino describes on the playground the usage of KTY81-110. If you have an other type, you need to recalculate the temperature.

(Vcc 5+)--+-->2.7k--+-->kty81-210-->(GND)
          |         |
          +->100nF--+-----> ADC2 (Analog Port 2)

Here is my code to use KTY81-210 with the arduino:

8 thoughts on “Arduino and KTY81-210

  1. Clemens

    Hi! Thx for your code. In case you are still using this code: There happened a mistake in
    float res_typ210[] = {980,1030,1135,1247,1367,1495,1630,1772,1922,2000,2080,2245,2417,2597,2785,2980,3192,3392,3607,3817,2915,4008,4166,4280};

    the 4th value, counting from the end, should be 3915,

  2. Mark

    Hi. I am compiling this code with latest Arduino 1.6.7 IDE on Arduino Uno R3 and i get following error:

    Arduino: 1.6.7 (Windows 10), Board: “Arduino/Genuino Uno”
    C:\Users\User\Documents\Arduino\tempSensor\tempSensor.ino: In function ‘float kty(unsigned int)’:
    tempSensor:41: error: unable to find a register to spill in class ‘POINTER_REGS’
    tempSensor:41: error: this is the insn:
    (insn 57 56 59 3 (set (reg:SF 71 [ D.4034 ])
    (mem:SF (post_inc:HI (reg:HI 8 r8 [orig:84 ivtmp.16 ] [84])) [2 MEM[base: _44, offset: 0B]+0 S4 A8])) C:\Users\User\Documents\Arduino\tempSensor\tempSensor.ino:33 99 {*movsf}
    (expr_list:REG_INC (reg:HI 8 r8 [orig:84 ivtmp.16 ] [84])

    C:\Users\User\Documents\Arduino\tempSensor\tempSensor.ino:41: confused by earlier errors, bailing out
    exit status 1
    unable to find a register to spill in class ‘POINTER_REGS’

    if i comment this line, it compiles ok:
    temp = map(resistance,res_typ210[i-1],res_typ210[i],temperature[i-1],temperature[i]);

    any idea?

    1. blog

      Thank you, for the comment.

      I have simplified my code and replace the linear regression with a polynomial trend function.
      Now the code is easier and use less memory.

  3. Staffel

    Thx for the code, it’s helpfull in some ways.
    I’m fairly new to arduino and have a question.
    Is there any way to make it (much) more precise? I’m making a thermostat and, and want to read the temperature to 0.1°C precision. I’m also using an KTY81-210 I was thinking about an equation, but don’t know how to implement that into a function. Do you have any suggestions/tips?

  4. Andrzej

    Did similar recalculations, but just reduced huge and nano numbers in recalculations. After the tests the results are more precise, here is my code:
    float kty(unsigned int port) {
    // resistor value of voltage divider in ohm
    float resistor = 2.7;
    float sensorValue = analogRead(0);
    float resistance = sensorValue / (1023.0 – sensorValue) * resistor;
    return 0.4616 * pow(resistance,6) – 6.8569 * pow(resistance,5) + 41.072 * pow(resistance,4) – 124.4 * pow(resistance,3) + 187.43 * pow(resistance,2) – 47.345 * resistance – 102.0;

  5. Ueli

    Hi, I’m somehow struggle with the polynomial trend.
    when I use the function above with a kty81-210 connected as described I receive negative temperature values of ~-140°C instead of the room temperature (~25°C). Can you explain this function a little bit more in detail?


Leave a Reply

Your email address will not be published. Required fields are marked *