KY-015 Temperature and Humidity Sensor Module

View on Amazon
Overview
About KY-015 Temperature and Humidity Sensor Module
The KY-015 Temperature and Humidity Sensor Module integrates the DHT11 sensor, capable of measuring temperatures from 0°C to 50°C with an accuracy of ±2°C, and relative humidity levels from 20% to 90% with an accuracy of ±5%. It communicates using a single-wire digital protocol, making it straightforward to interface with microcontrollers like Arduino and ESP32. Due to its low sampling rate, the sensor provides new readings approximately every two seconds, making it suitable for applications such as climate monitoring, greenhouse management, and environmental data logging.
Get Your KY-015
💡 Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
KY-015 Specifications
Complete technical specification details for KY-015 Temperature and Humidity Sensor Module
📊 Technical Parameters
KY-015 Pinout
The **KY-015** is a 3-pin temperature and humidity sensor module based on the DHT11:
Visual Pinout Diagram

Pin Types
Quick Tips
**Interface**: 1-Wire DHT protocol (proprietary single-wire),🌡️ **Temperature**: 0°C to 50°C range, ±2°C accuracy
**Humidity**: 20% to 90% RH, ±5% accuracy,⚡ **Power**: 3.3V or 5V operation
**Sampling**: 2-second interval (slow refresh rate),💡 **Based On**: DHT11 digital sensor chip
Pin Descriptions
| Pin Name | Type | Description | Notes |
|---|---|---|---|
1 Pin (-) | Power | Ground connection | |
2 Pin (middle) | Power | Power supply | 3.3V to 5V |
3 Pin (S) | Communication | Digital signal output | 1-Wire DHT protocol |
Wiring KY-015 to ESP32
To interface the **KY-015** with an **ESP32** using DHT protocol:
Visual Wiring Diagram

Connection Status
Protocol
Pin Connections
| KY-015 Pin | Connection | ESP32 Pin | Description |
|---|---|---|---|
1 Pin (-) Required | GND | Ground | |
2 Pin (middle) Required | 3.3V or 5V | Power supply | |
3 Pin (S) Required | GPIO4 | DHT data line (any GPIO) |
**No Pull-up Needed**: Module typically includes built-in pull-up resistor
**GPIO Selection**: Can use any GPIO pin, GPIO4 is just an example
**Voltage**: Use 3.3V for ESP32 compatibility
**Sampling Delay**: Wait at least 2 seconds between readings
KY-015 Troubleshooting
Common issues and solutions to help you get your sensor working
Common Issues
Issue: The sensor is not providing any data.
Solutions:
- Ensure all connections are secure and correctly placed.
- Verify that the microcontroller pin connected to the sensor's data pin is correctly configured as an input.
- Confirm that the sensor is receiving adequate power (3.3V or 5V).
Issue: The sensor outputs incorrect or unstable temperature and humidity values.
Solutions:
- Check for electromagnetic interference from nearby devices; try to isolate the sensor from potential sources of interference.
- Ensure that the sensor is not exposed to condensation or water droplets, which can affect readings.
- Allow the sensor to stabilize in the environment for a few minutes before taking readings.
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-015 Programming Examples
Ready-to-use code examples for different platforms and frameworks
#include <DHT.h>
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println("KY-015 Test - Temperature and Humidity:");
dht.begin();
}
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" % ");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" °C");
}This Arduino code utilizes the DHT library to read temperature and humidity data from the KY-015 sensor. The sensor is connected to digital pin 2, and the readings are displayed on the serial monitor every two seconds.
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "dht.h"
#define DHT_PIN GPIO_NUM_4
void app_main(void) {
printf("KY-015 Sensor Test\n");
while (1) {
int16_t temperature = 0;
int16_t humidity = 0;
if (dht_read_data(DHT_TYPE_DHT11, DHT_PIN, &humidity, &temperature) == ESP_OK) {
printf("Humidity: %d.%d%% Temperature: %d.%d°C\n", humidity / 10, humidity % 10, temperature / 10, temperature % 10);
} else {
printf("Could not read data from sensor\n");
}
vTaskDelay(pdMS_TO_TICKS(2000));
}
}This ESP-IDF code reads temperature and humidity data from the KY-015 sensor using the DHT11 library. The sensor is connected to GPIO4, and data is printed to the console every 2 seconds. If the reading fails, an error message is displayed.
sensor:
- platform: dht
pin: GPIO4
model: DHT11
temperature:
name: "KY-015 Temperature"
humidity:
name: "KY-015 Humidity"
update_interval: 2sThis ESPHome configuration sets up the KY-015 temperature and humidity sensor using the DHT11 protocol. The sensor is connected to GPIO4, and readings are updated every 2 seconds.
platformio.ini
[env:esp32]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
adafruit/DHT sensor librarymain.cpp
#include <Arduino.h>
#include <DHT.h>
#define DHTPIN 4 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
Serial.println("KY-015 Test - Temperature and Humidity:");
dht.begin();
}
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" % ");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" °C");
}This PlatformIO code reads the KY-015 sensor data using the DHT library. It prints temperature and humidity values every 2 seconds, with error handling for failed sensor readings.
import dht
import machine
import time
sensor = dht.DHT11(machine.Pin(4))
while True:
try:
sensor.measure()
temp = sensor.temperature()
humidity = sensor.humidity()
print("Temperature:", temp, "°C", " Humidity:", humidity, "%")
except OSError as e:
print("Failed to read sensor.")
time.sleep(2)This MicroPython script reads temperature and humidity data from the KY-015 sensor connected to GPIO4. It updates readings every 2 seconds and handles errors in case of sensor failure.
Wrapping Up KY-015
The ESP32 KY-015 Temperature and Humidity 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-015 into your ESP32 project and bring your ideas to life!
Explore Alternative Sensors
Looking for alternatives to the KY-015? Check out these similar sensors that might fit your project needs.

KY-001 Temperature Sensor Module
The KY-001 is a temperature sensor module that operates within a wide temperature range. It supports 1-Wire communication and is based on...

KY-033 Line Tracking Sensor Module
The KY-033 is a line tracking sensor module that detects light-reflective and light-absorbing surfaces using infrared technology. It...

KY-054 Phototransistor Module
The KY-054 is a phototransistor module that detects ambient light levels and provides an analog voltage output proportional to the light...





