KY-013 Analog Temperature Sensor Module


Analog Temperature Sensor module KY-013 for Arduino, measures ambient temperature based on resistance of the thermistor.



KY-013 Specifications

The KY-013 Analog Temperature Sensor module consist of a NTC thermistor and a 10 kΩ resistor. The resistance of the thermistor varies with surrounding temperature, we'll use the Steinhart–Hart equation to derive precise temperature of the thermistor.

Operating Voltage5V
Temperature measurement range-55°C to 125°C [-67°F to 257°F]
Measurement Accuracy±0.5°C


KY-013 Connection Diagram

Connect board's power line (middle) and ground (-) to 5V and GND respectively. Connect signal (S) to pin A0 on the Arduino.

S A0
middle 5V

Some KY-013 boards are labeled incorrectly,  if you are getting inverted readings (temperature drops when sensor is heated) try swapping power(middle) and ground (-).

Arduino KY-013 analog temperature sensor module connection diagramclick to enlarge

KY-013 Example Code

The following Arduino Sketch will derive the temperature of the thermistor using the Steinhart-Hart equation. The code will return temperature in Celcius, uncomment line 17 to get temperature in farenheit.

int ThermistorPin = A0;
int Vo;
float R1 = 10000; // value of R1 on board
float logR2, R2, T;
float c1 = 0.001129148, c2 = 0.000234125, c3 = 0.0000000876741; //steinhart-hart coeficients for thermistor

void setup() {

void loop() {
  Vo = analogRead(ThermistorPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0); //calculate resistance on thermistor
  logR2 = log(R2);
  T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2)); // temperature in Kelvin
  T = T - 273.15; //convert Kelvin to Celcius
 // T = (T * 9.0)/ 5.0 + 32.0; //convert Celcius to Farenheit

  Serial.print("Temperature: "); 
  Serial.println(" C"); 


The coeficients only apply to boards with a 10KΩ thermistors, some rare boards have 100KΩ thermistors and need different coeficients.
If the displayed temperature drops when heating the thermistor and viceversa a try swapping power and ground, apparently these boards are commonly mislabeled.

Leave a Reply

6 Comment threads
5 Thread replies
Most reacted comment
Hottest comment thread
9 Comment authors
HIGUYSSArduinoModulesDohn shootl00Viktor Recent comment authors

Hi, i copied and pasted to your Arduino code. But the result is not to make any sense. The possible temperature should be between 19-23 C but on the serial port as like: 85-90 C. I try to change the temperature calculation but the problem is not solved. Pls help


It’s probably trivial (I’m a total noob), but could you explain the first line of the Thermister function:
Temp = log(((10240000/RawADC) – 10000));
The way I see it, RawADC is a electric tension measure going from 0 to 1023. Therefore, the resistance R in the Steinhart–Hart equation should be proportional to it according to Ohm’s law. I don’t get why you divide by it.


If the equation on line 5 is to be used (1024 should better be 1023.0), the Vcc and ground connections need to be switched to get the correct thermistor resistance values (i.e., ground connected to the middle pin). After some experimentation, I realized that the A B C values on line 6 are meant for a 10K thermistor. I am not sure if the original KY-013 uses a 10K thermistor. The unit I got from the KUMAN kit uses a 100K thermistor, therefore the confusion (the KUMAN program is also seriously wrong, in multiple places…). If your board also uses a 100K thermistor, the following equations can be used to salvage the situation: //the correct resistance, assuming the center pin being connected to ground and “-” to Vcc: double Rt= 10000 * (1023.0/RawADC-1); //alternatively, if the center pin is connected to Vcc as in the figure above: double Rt= 10000/(1023.0/RawADC-1);… Read more »


Thank you so much! I have the same kit and the same unnamed thermistor. Your post saved me after hours of bashing my head over negative readings!

Dohn shoot
Dohn shoot

Thanks for sorting that out!


The equation on line 5 for the log of thermistor resistance is wrong !!!!!
Should be Temp = log( 10000/(1023.0/RawADC-1) );
The A B C values given on line 6 are all off too.
Please update the ABC values

Kenneth L. Anderson
Kenneth L. Anderson

” if you are getting inverted readings (temperature drops when sensor is heated) try swapping signal (S) and ground (-).” That is a mis-statement. These boards commonly are built with the (-) pin needing to be connected to the positive supply volts and the middle pin to the negative, or reference volts. If the S pin, as you suggest, becomes connected to one or the other excitation supply pins, the circuit ends up no longer being a voltage divider; that is, the two resistive components are no longer in series with each other between the reference and the excitation voltage. You’ll ONLY end up with a valid voltage divider circuit by supplying the excitation voltage right side up or upside down; i.e., the output of the voltage divider always has to be the ‘S’ pin. Leave that pin alone.

Daniel Salazar Dominguez
Daniel Salazar Dominguez

hi, iam using arduino IDE 1.8.5 and I get in the monitor serie a result of nanc (I believe the translation is “not a number” c) whats the problem?


A division by zero is the problem. You are receiving zero from pin A0.