0
\$\begingroup\$

Where's the error in the following circuit/code ?

Some time ago i got various sensors . One of those was the kty 10-6 (3 pieces). At the beginning i could not find any datasheet or examples about this temperature sensor. So i got an LM35 which was very simple to setup as it is linear. Now after various months i finally found the proper datasheet and the Mathematical equation to get the proper resistor values.

KTY 10-6 (this is the datasheet link)

Circuit

I found out that it is similar to the kty81-210

 (Vcc 5+)--+-->2.7k--+-->kty81-110-->(GND)
           |         |
           +->100nF--+-----> ADC0 (Analog Port 0)

As i have no 2.7k Ω resistor i used a 2200 ohm resistor.

the capacitor is 100nf i think: IJ63 is on top of the enclosure.correct?

schematic

simulate this circuit – Schematic created using CircuitLab

Code

As this thermistor is not linear and i always wanted to use the proper mathematical formula to calculate the temperature, this is the best solution. Based on what i read in the kty10-6 datasheet i changed some values like the resistor and the beta(a) value. the alpha(b) .00788 seems to be the same in both sensors.

float resistor = 2200; // changed
float temp = analogRead(A5);
float ukty = 5*temp/1023.0;
float a = 0.00001937*1000; // changed
float b = 0.00788*1000;
float c = 1000-resistor*ukty/(5-ukty);
float delta = b * b - 4 * a * c;
float delta1 = sqrt (delta);
float x2 =(-b + delta1)/(2 * a);
float temp1 = x2 + 25 ;

Is the calculation correct?

I ask beacuse even if its really hot these days .. i don't think there are 132-135°Celsius.The formula is for celsius.

Even if i don't use this formula but use other simpler calculations (linear) i always get over 130-140°Celsius

source1 source2 source3

Notes

If i touch the sensor the reading increases... as expected.

I tested on all analog pins.

I use the arduino micro.

I use it with a i2cLCD.

It's usb powered.

Nothing else is connected.

If i measure the resistor on the proto board when everything is turned off i read it as 1200ohm... the cap?

Why do i get 120 to 140 as a temperature value?


Optional

I just closed a post on electronics stack wich describes how to increase the thermistors resolution with resistors. found it

If someone knows how to change my circuit to read temperatures from -10/-20 to +40/+50 i would be very happy. this would duplicate the resolution. i think in my zone the temperatures will never go lower than -20 or higher than +50 ° Celsius.

I buyed 3 of those, i know they are cheap. I know about the nice DS##### Temp sensor which is perfect for the microcontrollers. But i want to get this one to work also.

\$\endgroup\$
  • \$\begingroup\$ Couldn't find any info - strange. I put Thermistor KTY 10-6 and got this straight away pollin.de/shop/downloads/D180003B.PDF \$\endgroup\$ – JIm Dearden Sep 3 '15 at 17:31
  • \$\begingroup\$ when i started using microcontyrollers... some months ago i searched for something like KIT 10 ... as the text on those temperature sensors are very degraded. anyway yeah i found it... it's an infineon... i also added the link in the post.its the first link just to be shure that if someone reads this he has easy access to it. \$\endgroup\$ – cocco Sep 3 '15 at 17:35
  • \$\begingroup\$ appart from that nice link , you have any ideas what could i have done wrong? i'm not an electronical enginer. \$\endgroup\$ – cocco Sep 3 '15 at 17:36
  • \$\begingroup\$ Added "this is the datasheet link" to the post if someone else misses it \$\endgroup\$ – cocco Sep 3 '15 at 17:42
  • \$\begingroup\$ Looking at the resistance at 25 degrees you should get a resistance of about 2000 ohm giving about 2.4V across the sensor. A quick check with a voltmeter should verify this. This should produce a reading of about 490 in the adc. Plug this value into your calculation and MANUALLY work through your program (pencil and paper). What value of temperature does it give ? (correct answer should be around 25) - If it doesn't then your formula/program is wrong \$\endgroup\$ – JIm Dearden Sep 3 '15 at 17:44
1
\$\begingroup\$

We know that analog readings will vary between 0 (=0V) and 1023 (5V).

First step is to convert the reading of the analog value (of voltage) into an actual resistance value.

enter image description here

Suggested new program (haven't tested this so comments/corrections welcome)

float resistorfixed = 2200;
float temp = analogRead(A5);

// calculate sensor resistance value (Rkty)

float Rkty = (resistorfixed * temp) / (1023 - temp);

// From the data sheet the value of the resistance of the sensor 
// @ 25 degrees is 2000 +/- 20 ohmsStart with calculating the measured 
// resistance.

float R25 = 2000;

// We are also given alpha and beta 

float alpha = 7.88 / 1000;
float beta  = 1.937 / 10000; 

// Now we need to calculate the temperature factor (KayTee)

float KayTee = Rkty / R25;

// We now have all the information to calculate the actual temperature 
// (AcT)

float AcT = 25 + ((sqrt((alpha * alpha) - (4 * beta) + (4 * beta * KayTee)) - alpha) / (2 * beta));

// Just hope I've got my brackets is the correct place!
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.