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
  • Educational projects for learning about sensors

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:

  • Operating Voltage: 3.3V to 5.5V
  • Temperature Range: 0°C to 50°C (±2°C accuracy)
  • Humidity Range: 20% to 90% RH (±5% accuracy)
  • Output Type: Digital signal
  • Communication Protocol: Single-wire serial interface
  • Sampling Rate: 1 reading per second (1 Hz)
  • Dimensions: 15mm x 12mm (approx.)

Pin Configuration:

The KY-012 module has three pins for easy interfacing with microcontrollers. The pinout is as follows:

Pin Name Description
1 VCC Power supply pin (3.3V to 5.5V)
2 DATA Digital output pin for temperature and humidity data
3 GND Ground connection

Usage Instructions

The KY-012 module is straightforward to use and can be easily interfaced with microcontrollers like the Arduino UNO. Below are the steps to use the module in a circuit:

Circuit Connection:

  1. Connect the VCC pin of the KY-012 to the 5V pin of the Arduino UNO.
  2. Connect the GND pin of the KY-012 to the GND pin of the Arduino UNO.
  3. Connect the DATA pin of the KY-012 to a digital input pin on the Arduino UNO (e.g., D2).
  4. Use a 10kΩ pull-up resistor between the DATA pin and the VCC pin to ensure stable communication.

Arduino Code Example:

The following code demonstrates how to read temperature and humidity data from the KY-012 module using the DHT library for Arduino:

// Include the DHT library for reading data from the KY-012 module
#include <DHT.h>

// Define the pin connected to the DATA pin of the KY-012
#define DHTPIN 2

// Define the type of DHT sensor (DHT11 in this case)
#define DHTTYPE DHT11

// Initialize the DHT sensor
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  // Start the serial communication for debugging
  Serial.begin(9600);
  Serial.println("KY-012 Temperature and Humidity Sensor Test");

  // Initialize the DHT sensor
  dht.begin();
}

void loop() {
  // Wait a few seconds between readings
  delay(2000);

  // Read humidity and temperature 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 KY-012 sensor!");
    return;
  }

  // Print the readings to the Serial Monitor
  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");
}

Important Considerations:

  • Ensure the module is powered within its operating voltage range (3.3V to 5.5V).
  • Use a pull-up resistor (10kΩ) on the DATA pin for stable communication.
  • Avoid placing the sensor in environments with condensation or extreme temperatures, as this may damage the module.
  • Allow the sensor to stabilize for a few seconds after powering it on before taking readings.

Troubleshooting and FAQs

Common Issues:

  1. No data or incorrect readings:

    • Ensure the wiring is correct and the pull-up resistor is connected.
    • Verify that the module is powered within the specified voltage range.
    • Check for loose connections or damaged wires.
  2. "Failed to read from KY-012 sensor!" message in Serial Monitor:

    • Ensure the correct pin is defined in the code (#define DHTPIN).
    • Confirm that the DHT library is installed and properly included in the code.
  3. Inconsistent or fluctuating readings:

    • Ensure the sensor is not exposed to rapid temperature or humidity changes.
    • Verify that the pull-up resistor is of the correct value (10kΩ).

FAQs:

Q: Can the KY-012 module be used outdoors?
A: The KY-012 is not waterproof and should not be exposed to rain or condensation. For outdoor use, consider placing it in a protective enclosure.

Q: How accurate is the KY-012 module?
A: The DHT11 sensor used in the KY-012 provides a temperature accuracy of ±2°C and a humidity accuracy of ±5%.

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 3.3V microcontrollers like the ESP8266 or ESP32.

Q: How often can I take readings from the KY-012?
A: The KY-012 has a sampling rate of 1 Hz, meaning you can take one reading per second.

By following the guidelines and troubleshooting tips provided, you can effectively use the KY-012 module in your projects.