KY-028 Digital Temperature Sensor Module

View on Amazon
Overview
About KY-028 Digital Temperature Sensor Module
The KY-028 Digital Temperature Sensor Module features an NTC thermistor for temperature measurement. It provides both analog and digital outputs, allowing for precise temperature readings and threshold-based alerts. The module includes an onboard potentiometer to adjust the temperature threshold for the digital output, making it suitable for various temperature monitoring applications.
Get Your KY-028
Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
KY-028 Specifications
Complete technical specification details for KY-028 Digital Temperature Sensor Module
📊 Technical Parameters
KY-028 Pinout
The **KY-028** is a 4-pin digital temperature sensor module with dual outputs:
Visual Pinout Diagram

Pin Types
Quick Tips
**Interface**: Dual output (analog + digital with comparator),🌡️ **Sensor**: NTC thermistor for temperature sensing
**Analog Output**: Continuous voltage reading proportional to temperature,🚨 **Digital Output**: Threshold-based alert (adjustable via potentiometer)
**Power**: 3.3V or 5V operation,🎚️ **Adjustment**: Onboard potentiometer to set temperature threshold
Pin Descriptions
| Pin Name | Type | Description | Notes |
|---|---|---|---|
1 GND | Power | Ground connection | |
2 +V | Power | Power supply | 3.3V or 5V |
3 A0 | Communication | Analog output | Voltage proportional to temperature |
4 D0 | Communication | Digital output | HIGH when temperature exceeds threshold |
Wiring KY-028 to ESP32
To interface the **KY-028** with an **ESP32** for temperature monitoring:
Visual Wiring Diagram

Connection Status
Protocol
Pin Connections
| KY-028 Pin | Connection | ESP32 Pin | Description |
|---|---|---|---|
1 GND Required | GND | Ground | |
2 +V Required | 3.3V or 5V | Power supply | |
3 A0 Optional | GPIO36 | Analog input (ADC pin) | |
4 D0 Optional | GPIO17 | Digital input (any GPIO) |
**Dual Use**: Can use analog output for precise readings or digital for threshold alerts
**ADC Pins**: Use GPIO32-39 for analog input on ESP32
**Voltage**: 3.3V recommended for ESP32 ADC compatibility
**Calibration**: Adjust onboard potentiometer to set digital trigger temperature
KY-028 Troubleshooting
Common issues and solutions to help you get your sensor working
Common Issues
Issue: The analog output does not change with temperature variations.
Solutions:
- Ensure proper connections to the analog output pin.
- Verify that the power supply voltage is within the specified range (3.3V to 5V).
- Check the thermistor for damage or disconnection.
Issue: The digital output does not change state when the temperature exceeds the set threshold.
Solutions:
- Adjust the potentiometer to set the desired temperature threshold.
- Ensure the comparator (LM393) is functioning correctly.
- Check the indicator LEDs to confirm module operation.
Debugging Tips
Use the Serial Monitor to check for error messages and verify the sensor's output. Add debug prints in your code to track the sensor's state.
Use a multimeter to verify voltage levels and check for continuity in your connections. Ensure the power supply is stable and within the sensor's requirements.
Additional Resources
KY-028 Programming Examples
Ready-to-use code examples for different platforms and frameworks
int led = 13; // LED output pin
int digitalPin = 2; // KY-028 digital interface
int analogPin = A0; // KY-028 analog interface
int digitalVal; // digital readings
int analogVal; // analog readings
void setup() {
pinMode(led, OUTPUT);
pinMode(digitalPin, INPUT);
Serial.begin(9600);
}
void loop() {
// Read the digital interface
digitalVal = digitalRead(digitalPin);
if (digitalVal == HIGH) { // if temperature threshold reached
digitalWrite(led, HIGH); // turn ON Arduino's LED
} else {
digitalWrite(led, LOW); // turn OFF Arduino's LED
}
// Read the analog interface
analogVal = analogRead(analogPin);
Serial.println(analogVal); // print analog value to serial
delay(100);
}This Arduino code reads both the digital and analog outputs of the KY-028 sensor. When the temperature exceeds the set threshold, the digital output goes HIGH, turning on the onboard LED connected to pin 13. The analog output provides a continuous reading corresponding to the temperature, which is printed to the serial monitor.
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/adc.h"
#include "driver/gpio.h"
#define TEMP_SENSOR_ANALOG_PIN ADC1_CHANNEL_0 // GPIO36
#define TEMP_SENSOR_DIGITAL_PIN GPIO_NUM_17
#define LED_PIN GPIO_NUM_16
void app_main(void) {
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(TEMP_SENSOR_ANALOG_PIN, ADC_ATTEN_DB_11);
gpio_set_direction(TEMP_SENSOR_DIGITAL_PIN, GPIO_MODE_INPUT);
gpio_set_direction(LED_PIN, GPIO_MODE_OUTPUT);
printf("KY-028 Temperature Sensor Test\n");
while (1) {
int analog_value = adc1_get_raw(TEMP_SENSOR_ANALOG_PIN);
int digital_value = gpio_get_level(TEMP_SENSOR_DIGITAL_PIN);
if (digital_value == 1) {
gpio_set_level(LED_PIN, 1); // Turn on LED
printf("Temperature threshold exceeded. Analog Value: %d\n", analog_value);
} else {
gpio_set_level(LED_PIN, 0); // Turn off LED
printf("Temperature within normal range. Analog Value: %d\n", analog_value);
}
vTaskDelay(pdMS_TO_TICKS(1000));
}
}This ESP-IDF code configures the KY-028 temperature sensor to read analog temperature values on GPIO36 and monitor the threshold-based digital output on GPIO17. If the temperature exceeds the set threshold, an LED on GPIO16 turns on, and the event is logged to the console.
sensor:
- platform: adc
pin: GPIO36
name: "KY-028 Temperature Analog"
update_interval: 1s
binary_sensor:
- platform: gpio
pin:
number: GPIO17
mode: INPUT_PULLUP
name: "KY-028 Temperature Threshold"This ESPHome configuration reads the KY-028 sensor's analog output on GPIO36 and detects the temperature threshold trigger using GPIO17 as a binary sensor. Updates are logged every second.
platformio.ini
[env:esp32]
platform = espressif32
board = esp32dev
framework = arduinomain.cpp
#include <Arduino.h>
#define TEMP_SENSOR_ANALOG_PIN A0
#define TEMP_SENSOR_DIGITAL_PIN 17
#define LED_PIN 16
void setup() {
pinMode(TEMP_SENSOR_DIGITAL_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.begin(115200);
Serial.println("KY-028 Temperature Sensor Test");
}
void loop() {
int analog_value = analogRead(TEMP_SENSOR_ANALOG_PIN);
int digital_value = digitalRead(TEMP_SENSOR_DIGITAL_PIN);
if (digital_value == HIGH) {
digitalWrite(LED_PIN, HIGH);
Serial.printf("Temperature threshold exceeded. Analog: %d\n", analog_value);
} else {
digitalWrite(LED_PIN, LOW);
Serial.printf("Temperature normal. Analog: %d\n", analog_value);
}
delay(1000);
}This PlatformIO code reads the KY-028 sensor's analog output and monitors the digital temperature threshold trigger. The values are printed every second, and an LED turns on when the temperature exceeds the set threshold.
import machine
import time
TEMP_SENSOR_ANALOG_PIN = machine.ADC(machine.Pin(36))
TEMP_SENSOR_ANALOG_PIN.atten(machine.ADC.ATTN_11DB)
TEMP_SENSOR_DIGITAL_PIN = machine.Pin(17, machine.Pin.IN, machine.Pin.PULL_UP)
LED_PIN = machine.Pin(16, machine.Pin.OUT)
while True:
analog_value = TEMP_SENSOR_ANALOG_PIN.read()
digital_value = TEMP_SENSOR_DIGITAL_PIN.value()
if digital_value:
LED_PIN.on()
print("Temperature threshold exceeded - Analog:", analog_value)
else:
LED_PIN.off()
print("Temperature normal - Analog:", analog_value)
time.sleep(1)This MicroPython script reads the KY-028 sensor's analog signal using ADC on GPIO36 and monitors the digital output on GPIO17. An LED on GPIO16 turns on when the temperature threshold is exceeded, and the readings are printed every second.
Wrapping Up KY-028
The ESP32 KY-028 Digital Temperature Sensor Module is a powerful KY-0xx module sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.
Best Practices
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Safety First
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.
Ready to Start Building?
Now that you have all the information you need, it's time to integrate the KY-028 into your ESP32 project and bring your ideas to life!








