KY-013 Analog Temperature Sensor Module

The KY-013 is an analog temperature sensor module utilizing an NTC thermistor. It provides temperature measurements in the range of -55°C to +125°C with an accuracy of ±0.5°C. Suitable for various temperature monitoring applications.

KY-013 Analog Temperature Sensor Module image
KY-013 · Analog
Analog
Interface
3pins
Connections
3.3V - 5 V
Supply
±0.5°C
Accuracy
-55 to +125 °C
Operating temp
$1
Typical price
On this page

KY-013 pinout

3 pins · Analog

The KY-013 is a 3-pin analog temperature sensor module with NTC thermistor:

View:
KY-013 Analog Temperature Sensor Module pinout
PinTypeDescriptionNotes
Pin (-)PowerGround connection
Pin (middle)PowerPower supply3.3V to 5V
Pin (S)CommunicationAnalog signal outputVoltage varies with temperature
  • Interface: Analog output (voltage divider)

  • Sensor: NTC thermistor (negative temperature coefficient)

  • Range: -55°C to +125°C

  • Accuracy: ±0.5°C (typical)

  • Power: 3.3V to 5V operation

  • Operation: Resistance decreases as temperature increases

Wiring the KY-013 to ESP32

3 connections · all required

To interface the KY-013 with an ESP32 for analog temperature reading:

Wiring diagram coming soon
The pin-to-pin table covers every connection.
KY-013 pinESP32 pinPurpose
Pin (-)GNDGround
Pin (middle)3.3V or 5VPower supply
Pin (S)GPIO36Analog input (ADC pin)
  • ADC Pins: Use GPIO32-39 for analog input on ESP32

  • Voltage: 3.3V recommended for ESP32 ADC range

  • Conversion: Requires Steinhart-Hart equation for accurate temperature

  • Filtering: Software averaging recommended for stable readings

KY-013 code examples

5 platforms
Platform:

KY-013 Arduino example

Copy
#include <math.h>

int sensorPin = 36; // Analog input (GPIO36 / ADC1_CH0, matches the wiring above)

void setup() {
    Serial.begin(115200);
}

void loop() {
    int rawValue = analogRead(sensorPin);
    // ESP32 ADC: 12-bit (0-4095) at 3.3V reference
    double voltage = rawValue * (3.3 / 4095.0);
    double resistance = (3.3 - voltage) * 10000 / voltage; // 10k series resistor
    // NTC thermistor: B = 3950, R0 = 10k at 25 C (298.15 K)
    double temperature = 1 / (log(resistance / 10000) / 3950 + 1 / 298.15) - 273.15;
    Serial.print("Temperature: ");
    Serial.print(temperature);
    Serial.println(" C");
    delay(1000);
}

The analog value is read on GPIO36 (ADC1) and converted using the ESP32's 12-bit range: voltage = raw * 3.3 / 4095. From the voltage the sketch derives the thermistor's resistance in the 10k voltage divider and applies the Beta equation (B = 3950, 10k at 25 C) to get the temperature. Analog readings on the ESP32 are noticeably noisier than on an Arduino Uno - average several readings for a steadier value.

KY-013 ESP-IDF example

Copy
#include <stdio.h>
#include <math.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/adc.h"

#define ADC_CHANNEL ADC1_CHANNEL_0 // GPIO36

void app_main(void) {
    adc1_config_width(ADC_WIDTH_BIT_12);
    adc1_config_channel_atten(ADC_CHANNEL, ADC_ATTEN_DB_11);

    while (1) {
        int raw = adc1_get_raw(ADC_CHANNEL);
        double voltage = raw * (3.3 / 4095.0);
        double resistance = (3.3 - voltage) * 10000 / voltage;
        double temperature = 1 / (log(resistance / 10000) / 3950 + 1 / 298.15) - 273.15;
        printf("Temperature: %.2f °C\n", temperature);
        vTaskDelay(pdMS_TO_TICKS(1000));
    }
}

This ESP-IDF code configures ADC1 on GPIO36 to read the analog signal from the KY-013 sensor. It calculates the temperature using the Steinhart-Hart equation and prints the result in Celsius every second.

KY-013 ESPHome example

Copy
sensor:
  - platform: ntc
    sensor: resistance_sensor
    name: "KY-013 Temperature Sensor"
    calibration:
      b_constant: 3950
      reference_temperature: 25°C
      reference_resistance: 10kΩ
  - platform: adc
    pin: GPIO36
    id: resistance_sensor
    update_interval: 1s

This ESPHome configuration sets up the KY-013 temperature sensor using an NTC thermistor on GPIO36. The resistance is measured via ADC, and the temperature is calculated using the Steinhart-Hart equation with a B-constant of 3950.

KY-013 PlatformIO example

Copy
[env:esp32]
platform = espressif32
board = esp32dev
framework = arduino
src/main.cppCopy
#include <Arduino.h>
#include <math.h>

#define SENSOR_PIN 36 // Analog input pin

void setup() {
    Serial.begin(115200);
}

void loop() {
    int rawValue = analogRead(SENSOR_PIN);
    double voltage = rawValue * (3.3 / 4095.0);
    double resistance = (3.3 - voltage) * 10000 / voltage;
    double temperature = 1 / (log(resistance / 10000) / 3950 + 1 / 298.15) - 273.15;
    Serial.printf("Temperature: %.2f °C\n", temperature);
    delay(1000);
}

This PlatformIO code configures the KY-013 temperature sensor on GPIO36. It reads the analog value, converts it to voltage, calculates the resistance, and then determines the temperature using the Steinhart-Hart equation.

KY-013 MicroPython example

Copy
import machine
import time
import math

SENSOR_PIN = 36  # ADC input pin
adc = machine.ADC(machine.Pin(SENSOR_PIN))
adc.atten(machine.ADC.ATTN_11DB)  # Full range 0-3.3V

def get_temperature():
    raw = adc.read()
    voltage = raw * (3.3 / 4095.0)
    resistance = (3.3 - voltage) * 10000 / voltage
    temperature = 1 / (math.log(resistance / 10000) / 3950 + 1 / 298.15) - 273.15
    return temperature

while True:
    print("Temperature:", round(get_temperature(), 2), "°C")
    time.sleep(1)

This MicroPython script reads the KY-013 sensor using ADC on GPIO36. It converts the voltage to resistance and then calculates the temperature using the Steinhart-Hart equation. The temperature is printed to the console every second.

KY-013 specifications

From the datasheet
Operating Voltage
3.3V - 5V
Temperature Range
-55°C to +125°C
Accuracy
±0.5°C
Thermistor Resistance
10 kΩ at 25°C
B-Value
3950K
Dimensions
19 x 15.5 x 7 mm

About the KY-013

The KY-013 is a bare 10 kOhm NTC thermistor wired into a voltage divider with a fixed resistor, so it reports temperature indirectly: as the thermistor heats up its resistance drops, and the divider’s output voltage shifts accordingly. Turning that voltage into a Celsius number takes real math on your side - the beta equation (a beta of 3950 K around the 25 degC/10 kOhm reference point is the commonly cited value for this style of module) or the fuller Steinhart-Hart formula - since there’s no chip on board doing that conversion for you.

That also means the accuracy quoted on cheap KY-013 listings is optimistic for what you actually get without individually calibrating each unit; component tolerances on the thermistor and the divider resistor both feed straight into the error. For a reading that’s accurate out of the box with no math required, a digital sensor like the DS18B20 - which the similarly-numbered KY-001 module is itself built around - or the SHT40 reports calibrated temperature directly over the wire. Wire the analog output to one of the ESP32’s ADC1 pins (GPIO32-39); the ADC2 pins share hardware with Wi-Fi and are best avoided for analog reads.

KY-013 troubleshooting

2 common issues

Incorrect Temperature Readings

›

Issue: The sensor outputs inaccurate or fluctuating temperature values.

Solutions:

  • Ensure stable power supply to the sensor.
  • Verify correct wiring connections, especially the analog signal pin.
  • Implement proper analog signal filtering in the code to reduce noise.

No Output from Sensor

›

Issue: The sensor provides no data or constant values.

Solutions:

  • Check for loose or incorrect connections.
  • Confirm that the analog input pin on the microcontroller is functioning correctly.
  • Test the sensor with a known temperature source to validate its operation.

Where to buy the KY-013

KY-013 Analog Temperature Sensor Module
KY-013 Analog Temperature Sensor Module
$1per unit, typical
Amazon and AliExpress links are affiliate links - buying through them supports the site at no extra cost to you.

Resources