Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Voltaat Arduino Ultimate Kit
60 min
Share

Monitor temperature and humidity using DHT11

The DHT11 is an amazing sensor that allows you to measure temperature in Celsius or Fahrenheit degrees and humidity in % using Arduino.

Project Video

Overview

In this tutorial, we will use the Arduino to print the temperature and humidity values on your computer using a suitable sensor called the DHT11.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
DHT11 Temperature & Humidity Sensor
Get Item
Jumper Wires - Male to Male (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wires between the DHT11 sensor and the Arduino. as shown in the image below.

 Connections from the Arduino to the DHT11:


      • Arduino GND pin → DHT11 GND pin (- pin)


      • Arduino 5V pin → DHT11 VCC pin (+ pin)


      • Arduino pin 3 → DHT11 out pin

Coding


/*
 Voltaat learn (http://learn.voltaat.com/)
 Link for full tutorial:
 Link for libraries:

 Tutorial: Monitor temperature and humidity using DHT11

 This is an Arduino sketch that monitor temperature in Celsius degrees and humidity
 in percentage by using the DHT11 sensor with Arduino

 Connections from the Arduino to the DHT11:
 • Arduino GND pin → DHT11 GND pin (- pin)
 • Arduino 5V pin → DHT11 VCC pin (+ pin)
 • Arduino pin 3 → DHT11 out pin

*/

//include the DHT sensor Library
#include "DHT.h"

//Define Parameters to DHT function, 3 Refers to digital pin 3 in arduino which you can change with any other digital pin, DHT11 is the sensor type.
DHT dht (3, DHT11);

//define two variables for Temperature and Humidity.
float Temperature, Humidity;

// Commands inside void setup run once.
void setup()
{
 //Initialize the DHT sensor with the begin() method.
 dht.begin();

 //Start the serial monitor at 9600 baud rate (9600 bits per second)
 Serial.begin(9600);
}

//Commands inside void loop run forever
void loop()
{
 //wait for 1 sec to get a stable reading from the sensor
 delay(1000);

 //Read the Temperature value from the sensor
 //You can use Temperature = dht.readTemperature(True); to print the temperature value in Fahrenheit.
 Temperature = dht.readTemperature();

 //Read the Humidity value from the sensor
 Humidity = dht.readHumidity();

 //print "The Temperature = " to the serial monitor
 Serial.print("The Temperature = ");

 //print temperature value at the same line
 Serial.print(Temperature);

 //print " Celsius" to the serial monitor at the same line
 Serial.print(" Celsius");

 //print "   The Humidity = " to the serial monitor at the same line
 Serial.print("   The Humidity = ");

 //print The Humidity value to the serial monitor at the same line
 Serial.print(Humidity);

 //print "%" sign to the serial monitor then add new line
 Serial.println("%");

}

Testing it Out

You should also make sure you have chosen the right baud rate (9600) as specified in the code.
know when your plant needs watering

Now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

know when your plant needs watering

Now as we see in the following image, the serial monitor displays temperature and humidity values. The value is updated and printed every second because of the delay we made in our code.

know when your plant needs watering

Resources

No items found.