Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO with DHT11 Temperature and Humidity Sensor

View and Edit Project In Cirkit DesignerImage of Arduino UNO with DHT11 Temperature and Humidity Sensor

Circuit Documentation

Summary of the Circuit

This circuit consists of an Arduino UNO microcontroller board interfaced with a KY-015 DHT11 temperature and humidity sensor module. The Arduino UNO is responsible for reading the environmental data captured by the DHT11 sensor and processing this information. The data is then output through the Arduino's serial communication interface, which can be monitored on a connected computer's serial monitor.

Component List

Arduino UNO

KY-015 DHT11

Wiring Details

Arduino UNO

KY-015 DHT11

Documented Code

The following code is written for the Arduino UNO and is used to interface with the KY-015 DHT11 temperature and humidity sensor. The code initializes the sensor and reads the temperature and humidity values, which are then printed to the serial monitor.

#include<dht.h> // dht library

// Define the pin connected to the DHT11 data pin
int tempPin = 3;

// Create an instance of the dht library
dht MyDHT;

void setup() {
  // Initialize the temperature pin as input
  pinMode(tempPin, INPUT);
  
  // Start serial communication at 9600 baud rate
  Serial.begin(9600);
}

void loop() {
  // Read the data from the DHT11 sensor
  int chk = MyDHT.read11(tempPin);
  
  // Retrieve the temperature and humidity from the DHT11 sensor
  int temperature = MyDHT.temperature;
  int humidity = MyDHT.humidity;
  
  // Print the temperature and humidity values to the serial monitor
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.print("°C, Humidity: ");
  Serial.print(humidity);
  Serial.println("%");
  
  // Wait a bit before reading the values again
  delay(2000);
}

The code includes the dht.h library, which provides the necessary functions to communicate with the DHT11 sensor. The tempPin variable is defined to represent the digital pin D3 on the Arduino UNO, which is connected to the sensor's data pin. In the setup() function, the pin mode is set to INPUT, and serial communication is started. The loop() function continuously reads the temperature and humidity values from the sensor and prints them to the serial monitor every 2 seconds.