Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use KY-012: Examples, Pinouts, and Specs

Image of KY-012
Cirkit Designer LogoDesign with KY-012 in Cirkit Designer

Introduction

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.

Explore Projects Built with KY-012

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Arduino Nano Joystick-Controlled Bluetooth Module with Battery Power
Image of padelpro transmitter: A project utilizing KY-012 in a practical application
This circuit is a wireless joystick controller that uses an Arduino Nano to read analog signals from a KY-023 Dual Axis Joystick Module and transmits the data via an HC-05 Bluetooth Module. The system is powered by a 18650 Li-Ion battery with a rocker switch for power control.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32-Based Security System with RFID and Laser Tripwire
Image of CPE doorlock system: A project utilizing KY-012 in a practical application
This circuit is designed for a comprehensive security and access control system with motion detection, access via RFID, and a break-beam sensor. It includes a solenoid lock controlled by a relay, visual and audible alerts, and a robust power management system with solar and battery backup to ensure uninterrupted operation.
Cirkit Designer LogoOpen Project in Cirkit Designer
Wireless Joystick-Controlled Interface with Arduino Nano and NRF24L01
Image of Transmitter 11: A project utilizing KY-012 in a practical application
This circuit features an Arduino Nano interfaced with a KY-023 Dual Axis Joystick Module for analog input, and an NRF24L01 module for wireless communication. The joystick provides x and y-axis control signals to the Arduino's analog inputs and a switch signal to a digital input, while the NRF24L01 enables the Arduino to communicate with other devices wirelessly. The 2x 18650 batteries supply power to the Arduino, which in turn powers the joystick and the NRF24L01 module.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32-Based Security System with RFID and Laser Intrusion Detection
Image of CPE doorlock system upgrade: A project utilizing KY-012 in a practical application
This circuit is a security and access control system featuring motion detection, laser beam-break sensing, and RFID scanning, interfaced with a keypad and visual/audible indicators, powered by a solar-charged battery, and capable of controlling an electric lock via a relay.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with KY-012

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of padelpro transmitter: A project utilizing KY-012 in a practical application
Arduino Nano Joystick-Controlled Bluetooth Module with Battery Power
This circuit is a wireless joystick controller that uses an Arduino Nano to read analog signals from a KY-023 Dual Axis Joystick Module and transmits the data via an HC-05 Bluetooth Module. The system is powered by a 18650 Li-Ion battery with a rocker switch for power control.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of CPE doorlock system: A project utilizing KY-012 in a practical application
ESP32-Based Security System with RFID and Laser Tripwire
This circuit is designed for a comprehensive security and access control system with motion detection, access via RFID, and a break-beam sensor. It includes a solenoid lock controlled by a relay, visual and audible alerts, and a robust power management system with solar and battery backup to ensure uninterrupted operation.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Transmitter 11: A project utilizing KY-012 in a practical application
Wireless Joystick-Controlled Interface with Arduino Nano and NRF24L01
This circuit features an Arduino Nano interfaced with a KY-023 Dual Axis Joystick Module for analog input, and an NRF24L01 module for wireless communication. The joystick provides x and y-axis control signals to the Arduino's analog inputs and a switch signal to a digital input, while the NRF24L01 enables the Arduino to communicate with other devices wirelessly. The 2x 18650 batteries supply power to the Arduino, which in turn powers the joystick and the NRF24L01 module.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of CPE doorlock system upgrade: A project utilizing KY-012 in a practical application
ESP32-Based Security System with RFID and Laser Intrusion Detection
This circuit is a security and access control system featuring motion detection, laser beam-break sensing, and RFID scanning, interfaced with a keypad and visual/audible indicators, powered by a solar-charged battery, and capable of controlling an electric lock via a relay.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications:

  • Weather monitoring systems
  • Home automation for climate control
  • Greenhouse and agricultural monitoring
  • IoT-based environmental sensing projects

Technical Specifications

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:

Key Specifications:

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

Pin Configuration:

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

Usage Instructions

How to Use the KY-012 in a Circuit:

  1. Power the Module: Connect the VCC pin to a 3.3V or 5V power source and the GND pin to the ground.
  2. Connect the Data Pin: Attach the 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.
  3. Read Data: Use a compatible library or implement the 1-wire protocol to read temperature and humidity data from the module.

Important Considerations:

  • Sampling Interval: The DHT11 sensor requires a minimum sampling interval of 2 seconds. Reading data more frequently may result in inaccurate measurements.
  • Environmental Conditions: Avoid exposing the sensor to extreme temperatures or humidity levels beyond its specified range, as this may damage the sensor or reduce accuracy.
  • Wiring Length: Keep the wiring between the module and the microcontroller as short as possible to minimize signal degradation.

Example Code for Arduino UNO:

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");
}

Notes:

  • Install the 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."
  • Ensure the DHTPIN in the code matches the digital pin connected to the KY-012 DATA pin.

Troubleshooting and FAQs

Common Issues:

  1. No Data Output:

    • Cause: Incorrect wiring or missing pull-up resistor.
    • Solution: Double-check the connections and ensure a 10kΩ pull-up resistor is used between the DATA pin and VCC.
  2. Invalid Readings (NaN):

    • Cause: Sensor not initialized properly or sampling interval too short.
    • Solution: Verify the sensor initialization in the code and ensure a delay of at least 2 seconds between readings.
  3. Inconsistent Measurements:

    • Cause: Electrical noise or long wiring.
    • Solution: Use shorter wires and ensure proper grounding. Adding a capacitor (e.g., 100nF) across VCC and GND can help stabilize the power supply.

FAQs:

  • 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.