KY-015 Combi-Sensor (temperature & humidity)
This sensor is a mixture of temperature sensor and humidity sensor in a compact design.
- Arduino
- Raspberry Pi
- Raspberry Pi Pico
- Micro:Bit

This sensor is a combination of temperature sensor and humidity sensor, united in a compact design. The disadvantage is the low sampling rate of the measurement, so that only every 2 seconds a new measurement result is available. This sensor is therefore particularly suitable for long-term measurements.
Technical data
Chipset | DHT11 |
Communication Protocol | 1-Wire |
Measuring range | 0 °C to 50 °C |
Measurement accuracy | ±2 °C |
Measurement Accuracy | ±5%RH |
Measurable humidity | 20-90%RH |
Pin assignment
Code example Arduino
Pin assignment Arduino
Arduino | Sensor |
---|---|
Pin 2 | Signal |
5 V | +V |
GND | GND |
For the following code example an additional library is needed:
DHT-sensor-library by Adafruit | published under the MIT License.
This sensor does not output its measurement result as an analog signal to an output pin, but communicates it digitally encoded.
The example below uses the mentioned library. Therefore, download the library and unpack it into your Arduino library folder, which by default is located at (C:\User[username]\Documents\Arduino\libraries). Alternatively, it is also included in the download package below.
// Adafruit_DHT library is inserted
#include "DHT.h"
// Here the respective input pin can be declared
#define DHTPIN 2
// The sensor is initialized
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600);
Serial.println("KY-015 test - temperature and humidity test:");
// Measurement is started
dht.begin();
}
// Main program loop
// The program starts the measurement and reads out the measured values
// There is a pause of 2 seconds between measurements,
// so that a new measurement can be acquired on the next run.
void loop() {
// Two seconds pause between measurements
delay(2000);
// Humidity is measured
float h = dht.readHumidity();
// temperature is measured
float t = dht.readTemperature();
// Checking if the measurements have passed without errors
// if an error is detected, a error message is displayed here
if (isnan(h) || isnan(t)) {
Serial.println("Error reading the sensor");
return;
}
// Output to serial console
Serial.println("-----------------------------------------------------------");
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(char(186)); //Output <°> symbol
Serial.println("C ");
Serial.println("-----------------------------------------------------------");
Serial.println(" ");
}
Please note that the sensor provides a new measurement result only about every 2 seconds.
Example program download

This sensor is a combination of temperature sensor and humidity sensor, united in a compact design. The disadvantage is the low sampling rate of the measurement, so that only every 2 seconds a new measurement result is available. This sensor is therefore particularly suitable for long-term measurements.
Technical data
Chipset | DHT11 |
Communication Protocol | 1-Wire |
Measuring range | 0 °C to 50 °C |
Measurement accuracy | ±2 °C |
Measurement Accuracy | ±5%RH |
Measurable humidity | 20-90%RH |
Pin assignment
Code example Raspberry Pi
Pin assignment Raspberry Pi
Raspberry Pi | Sensor |
---|---|
GPIO 23 [Pin 16] | Signal |
+3.3 V [Pin 1] | +V |
GND [Pin 6] | GND |
The program uses the corresponding Adafruit_CircuitPython_DHT library from Adafruit to control the DHT11 sensor, which is installed on this sensor module. This was released with the MIT OpenSource license.
This must be installed beforehand. Therefore, first update your package list and install the required dependencies using the following commands:
sudo apt-get update
sudo apt-get install build-essential python-dev
sudo apt install gpiod
sudo pip3 install adafruit-circuitpython-dht
Now the following Python example can be used. The program starts the measurement at the sensor and outputs the measured values for the air pressure and the temperature (in °C and °F).
import time
import board
import adafruit_dht
# Initialize the dht device with the data pin connected to pin 16 (GPIO 23) of the Raspberry Pi:
dhtDevice = adafruit_dht.DHT11(board.D23)
# You can pass DHT22 use_pulseio=False if you do not want to use pulseio.
# This may be necessary on a Linux single board computer like the Raspberry Pi,
# but it will not work in CircuitPython.
# dhtDevice = adafruit_dht.DHT22(board.D18, use_pulseio=False)
while True:
try:
# Print the values via the serial interface
temperature_c = dhtDevice.temperature
temperature_f = temperature_c * (9 / 5) + 32
humidity = dhtDevice.humidity
print("Temp: {:.1f} F / {:.1f} C Humidity: {}% ".format(temperature_f, temperature_c, humidity))
except RuntimeError as error:
# Errors happen quite often, DHT's are hard to read, just move on
print(error.args[0])
time.sleep(2.0)
continue
except Exception as error:
dhtDevice.exit()
raise error
time.sleep(2.0)
Please note that the sensor provides a new measurement result only about every 2 seconds.
Example program download
To start with the command:
sudo python3 KY015-RPi.py

This sensor is a combination of temperature sensor and humidity sensor, united in a compact design. The disadvantage is the low sampling rate of the measurement, so that only every 2 seconds a new measurement result is available. This sensor is therefore particularly suitable for long-term measurements.
Technical data
Chipset | DHT11 |
Communication Protocol | 1-Wire |
Measuring range | 0 °C to 50 °C |
Measurement accuracy | ±2 °C |
Measurement Accuracy | ±5%RH |
Measurable humidity | 20-90%RH |
Pin assignment
Code example Micro:Bit
Pinout Micro:Bit:
Micro:Bit | Sensor |
---|---|
Pin 1 | Signal |
3 V | +V |
GND | GND |
An additional library is needed for the following code example:
pxt-DHT11_DHT22 from alankrantas | published under the MIT License.
You must add this library to your IDE before using the code. Add the library to your IDE by clicking Extensions and typing the following URL in the search box: https://github.com/alankrantas/pxt-DHT11_DHT22.git. Bestätigen Sie die Suche mit [Enter].

Sample program download

This sensor is a combination of temperature sensor and humidity sensor, united in a compact design. The disadvantage is the low sampling rate of the measurement, so that only every 2 seconds a new measurement result is available. This sensor is therefore particularly suitable for long-term measurements.
Technical data
Chipset | DHT11 |
Communication Protocol | 1-Wire |
Measuring range | 0 °C to 50 °C |
Measurement accuracy | ±2 °C |
Measurement Accuracy | ±5%RH |
Measurable humidity | 20-90%RH |
Pin assignment
Code example Raspberry Pi Pico
Pin assignment Raspberry Pi Pico
Raspberry Pi Pico | Sensor |
---|---|
GPIO14 | Signal |
3.3V | +V |
GND | GND |
For the following code example an additional library is needed:
micropython-stubs by Jos Verlinde | published under the MIT License
This sensor does not output its measurement result as an analog signal on an output pin, but communicates it digitally encoded.
# Load libraries
from machine import Pin
from utime import sleep
from dht import DHT11
# Initialization GPIO14 and DHT11
sleep(1)
dht11_sensor = DHT11(Pin(14, Pin.IN, Pin.PULL_UP))
# Repeat (endless loop)
while True:
# Perform measurement
dht11_sensor.measure()
# Read values
temp = dht11_sensor.temperature()
humi = dht11_sensor.humidity()
# Output values
print("Temperature: {}°C Humidity: {:.0f}% ".format(temp, humi))
print()
sleep(3)
Please note that the sensor provides a new measurement result only about every 2 seconds.