Arca
Published © MPL-2.0

Using DHT11

This tutorial will show you how to use DHT11 with Arduino.

BeginnerProtip187,790
Using DHT11

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
You can use DHT11 with 3 pins, DHT11 with 4 pins or DHT22.
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Or Arduino Web Editor

Story

Read more

Schematics

Schematics

Code

DHT11.ino

Arduino
The code for receiving the data from the DHT11 and printing it out on the serial monitor.
#include <dht11.h>
#define DHT11PIN 4

dht11 DHT11;

void setup()
{
  Serial.begin(9600);
 
}

void loop()
{
  Serial.println();

  int chk = DHT11.read(DHT11PIN);

  Serial.print("Humidity (%): ");
  Serial.println((float)DHT11.humidity, 2);

  Serial.print("Temperature (C): ");
  Serial.println((float)DHT11.temperature, 2);

  delay(2000);

}

DHT11 Library

Don't forget to add this library to the Arduino IDE.

Credits

Arca

Arca

1 project • 47 followers

Comments