# KY-013 Analog Temperature Sensor Module

### Description

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 Voltage 5V 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.

 KY-013 Arduino S A0 middle 5V - GND

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 (-).

### 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() {
Serial.begin(9600);
}

void loop() {
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.print(T);
Serial.println(" C");

delay(500);
}
``````

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. Inline Feedbacks   wpDiscuz