
Description
The KY-013 Analog Temperature Sensor module is a sensor Based on the thermistor's resistance on the board, it can calculate the ambient temperature it has an operating Voltage of 5V and the temperature measurement range is from -55°C to 125°C [-67°F to 257°F] with measurement Accuracy of ±0.5°C. compatible with well-liked electronic hardware platforms like the Arduino and ESP32. Thermistors are straightforward, reasonably priced, and precise components that make obtaining temperature information for your projects simple. The use of thermistors would be best in remote weather stations, home automation systems, and equipment control and protection circuits, to name a few. The code is relatively straightforward because they are analog sensors as opposed to digital temperature sensors, which call for complex libraries and a lot of code.
Specifications
This module consists of a NTC thermistor, a 10 kΩ resistor, and 3 male header pins. The thermistor's resistance varies according to its surrounding temperature. The value of resistance can be used to calculate the actual temperature.
Operating Voltage | 5V |
Temperature measurement range | -55°C to 125°C [-67°F to 257°F] |
Measurement Accuracy | ±0.5°C |
Â
Â
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 |
---|---|
S | A0 |
middle | 5V |
– | GND |
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() {
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.print(T);
Serial.println(" C");
delay(500);
}