5% OFF Over $19, Code: Elephant5; 10% OFF Over $59, Code: Elephant10



Arduino UNO R3/MEGA 2560 R3 Project 30: DHT11 Temperature and Humidity Sensor

Posted by Fiona Su on

Introduction

This DHT11 Temperature and Humidity Sensor features calibrated digital signal output with the temperature and humidity sensor complex. Its technology ensures high reliability and excellent long-term stability. A high-performance 8-bit microcontroller is connected. This sensor includes a resistive element and a sense of wet NTC temperature measuring devices. It has the advantages of excellent quality, fast response, anti-interference ability and high cost performance.
Each DHT11 sensor features extremely accurate calibration data of humidity calibration chamber. The calibration coefficients stored in the OTP program memory, internal sensors detect signals in the process, and we should call these calibration coefficients. The single-wire serial interface system is integrated to make it quick and easy.
Qualities of small size, low power, and 20-meter signal transmission distance make it a widely applied application and even the most demanding one. Convenient connection and special package can be provided according to your need.

thumb

Video Tutorial


Specification

  • Supply Voltage: +5 V
  • Temperature Range: 0-50 °C error of ± 2 °C
  • Humidity: 20-90% RH ± 5% RH error
  • Interface: Digital

Connection

Connection for REV4:
This module adopts the IIC test method, so only need to connect ‘SDA’ to Arduino A4, ‘SCL’ to A5, ‘+’ to VCC and ‘-’ to GND as follows:


0078-49png.png

Connection for 2560 R3:

Ks0399 connect24-1.png

Sample Code

Please download the DHT11Lib firstly. Or see the website 

#include <dht11.h>
dht11 DHT;
#define DHT11_PIN 4
  
void setup(){
  Serial.begin(9600);
  Serial.println("DHT TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");
  Serial.println(DHT11LIB_VERSION);
  Serial.println();
  Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}
  
void loop(){
  int chk;
  Serial.print("DHT11, \t");
  chk = DHT.read(DHT11_PIN);    // READ DATA
  switch (chk){
    case DHTLIB_OK:  
                Serial.print("OK,\t"); 
                break;
    case DHTLIB_ERROR_CHECKSUM: 
                Serial.print("Checksum error,\t"); 
                break;
    case DHTLIB_ERROR_TIMEOUT: 
                Serial.print("Time out error,\t"); 
                break;
    default: 
                Serial.print("Unknown error,\t"); 
                break;
  }
 // DISPLAT DATA
  Serial.print(DHT.humidity,1);
  Serial.print(",\t");
  Serial.println(DHT.temperature,1);
  
  delay(1000);
}

Result

Wire it up well and upload the above code to REV4 board.

0078-50png.png

Then open the serial monitor and set the baud rate to 9600, you will see the current temperature and humidity value.

Ks0399 Result24-1.png

All Tutorial

Buy 

0 comments

Leave a comment

Please note, comments must be approved before they are published