

The KY-012 is a temperature and humidity sensor module that integrates the DHT11 sensor. It is designed to provide digital output for both temperature and humidity readings, making it an ideal choice for environmental monitoring applications. The module is widely used in weather stations, home automation systems, and agricultural monitoring setups due to its simplicity and reliability.








The KY-012 module is built around the DHT11 sensor, which offers reliable performance for basic temperature and humidity sensing needs. Below are the key technical details:
| Parameter | Value |
|---|---|
| Operating Voltage | 3.3V to 5.5V |
| Temperature Range | 0°C to 50°C |
| Temperature Accuracy | ±2°C |
| Humidity Range | 20% to 90% RH |
| Humidity Accuracy | ±5% RH |
| Output Signal | Digital (1-wire protocol) |
| Sampling Period | ≥ 2 seconds |
| Dimensions | 23mm x 12mm x 5mm |
The KY-012 module has three pins for easy interfacing with microcontrollers. The pinout is as follows:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | VCC | Power supply (3.3V to 5.5V) |
| 2 | DATA | Digital data output |
| 3 | GND | Ground connection |
VCC pin to a 3.3V or 5V power source and the GND pin to the ground.DATA pin to a digital input pin on your microcontroller. A pull-up resistor (typically 10kΩ) is recommended between the DATA pin and VCC to ensure stable communication.Below is an example of how to use the KY-012 module with an Arduino UNO. This code utilizes the DHT library for easy communication with the sensor.
#include <DHT.h>
// Define the pin connected to the KY-012 DATA pin
#define DHTPIN 2
// Define the sensor type (DHT11 for KY-012)
#define DHTTYPE DHT11
// Initialize the DHT sensor
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600); // Start serial communication at 9600 baud
dht.begin(); // Initialize the DHT sensor
Serial.println("KY-012 Temperature and Humidity Sensor Test");
}
void loop() {
delay(2000); // Wait at least 2 seconds between readings
// Read temperature and humidity values
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
// Check if the readings are valid
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Print the results to the Serial Monitor
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
}
DHT library in the Arduino IDE before uploading the code. You can find it in the Library Manager by searching for "DHT sensor library by Adafruit."DHTPIN in the code matches the digital pin connected to the KY-012 DATA pin.No Data Output:
DATA pin and VCC.Invalid Readings (NaN):
Inconsistent Measurements:
VCC and GND can help stabilize the power supply.Q: Can the KY-012 measure negative temperatures?
A: No, the DHT11 sensor used in the KY-012 module can only measure temperatures in the range of 0°C to 50°C.
Q: Is the KY-012 suitable for outdoor use?
A: The KY-012 is not waterproof or weatherproof. For outdoor applications, use a protective enclosure to shield the sensor from moisture and direct sunlight.
Q: Can I use the KY-012 with a 3.3V microcontroller?
A: Yes, the KY-012 operates within a voltage range of 3.3V to 5.5V, making it compatible with both 3.3V and 5V systems.
By following this documentation, you can effectively integrate the KY-012 module into your projects for reliable temperature and humidity monitoring.