# KY-013 Analog Temperature Sensor Module

The KY-013 Analog Temperature Sensor module can measure ambient temperature based on the resistance of the thermistor on the board.

Compatible with popular electronics platforms like Arduino and ESP32.

## KY-013 Specifications

This module consist of a NTC thermistor, a 10 kΩ resistor, and 3 male header pins. The thermistor resistance varies according to its surrounding temperature. The value of resistance can be used to calculate the actual temperature.

## Connection Diagram

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

Some KY-013 have a different pin arrangement. Please check your board before connecting.

## KY-013 Arduino Code

The following Arduino Sketch will derive the temperature from 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);
}
``````

### 20 thoughts on “KY-013 Analog Temperature Sensor Module”

1. The expression for calculating R2 is wrong (at least with my module). It should be like this:

R2 = R1*Vo/(1023-Vo);

Otherwise, I found the article helpful, thanks.