Arduino library for DHT11, DHT22, etc Temperature & Humidity Sensors
Go to file
MaxGracia98 e384d4aec6
DHT22 with proteus.
I made this changes in the library to make it works with DHT22 sensor in proteus.
2020-04-15 12:02:00 -05:00
.github Add GitHub issue template 2016-05-27 13:43:18 -07:00
examples Change initial HIGH delay, fix comments in examples 2019-01-28 17:05:54 -08:00
.gitignore Add .gitignore 2019-07-04 11:31:09 +02:00
.travis.yml added travis 2019-07-04 17:30:56 +02:00
CONTRIBUTING.md [Update URL] 2019-11-01 14:41:05 +05:00
DHT_U.cpp DHT_U doxygen 2019-07-04 17:28:10 +02:00
DHT_U.h DHT_U doxygen 2019-07-04 17:28:10 +02:00
DHT.cpp DHT22 with proteus. 2020-04-15 12:02:00 -05:00
DHT.h documented DHT 2019-07-04 17:06:42 +02:00
keywords.txt Use correct field separator in keywords.txt 2018-07-16 05:02:42 -07:00
library.properties Update library.properties 2019-11-02 14:51:31 -04:00
README.md [Fix contributor name and remove version section] 2019-11-01 23:08:43 +05:00

Adafruit DHT Humidity & Temperature Sensor Library Build Status

Description

An Arduino library for the DHT series of low-cost temperature/humidity sensors.

You can find DHT tutorials here.

Installation

First Method

image

  1. In the Arduino IDE, navigate to Sketch > Include Library > Manage Libraries
  2. Then the Library Manager will open and you will find a list of libraries that are already installed or ready for installation.
  3. Then search for DHT-sensor using the search bar.
  4. Click on the text area and then select the specific version and install it.

Second Method

  1. Navigate to the Releases page.
  2. Download the latest release.
  3. Extract the zip file
  4. In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library

Requirements

This library depends on Adafruit Unified Sensor Library. To use this library the user must download the required library.

Features

  • Inexpensive

    This library is used with low-cost temperature and humidity sensors, for example, DHT11 and DHT22. This library is free of cost and the only cost is of the sensors.

  • Compatible

    DHT sensor library is compatible with multiple low-cost temperature and humidity sensors like DHT11 and DHT22. A few examples are implemented just to demonstrate how to modify the code for different sensors.

  • Function calls

    Basic functions of the low-cost temperature/humidity sensors have been implemented in this library. There's no need to re-implement these functions from scratch. The user simply has to import the library in the project and can use any of its functions by just calling it.

  • Give back

    The library is free, you dont have to pay for anything. However, if you want to support the development, or just thank the author of the library by purchasing products from Adafruit!

    Not only youll encourage the development of the library, but youll also learn how to best use the library and probably some C++ too

  • MIT License

    DHT sensor library is open-source and uses one of the most permissive licenses so you can use it on any project.

    • Commercial use
    • Modification
    • Distribution
    • Private use

Functions

  • begin()
  • readTemperature()
  • convertCtoF()
  • convertFtoC()
  • readHumidity()
  • computeHeatIndex()
  • read()
  • expectPulse()

Example

Examples include both a "standalone" DHT example and one that works along with the Adafruit Unified Sensor Library. A Unified sensor library is required even if using the standalone version. You can find other examples from Github-DHT-sensor-library.

#include "DHT.h"

#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println(F("DHTxx test!"));

  dht.begin();
}

void loop() {
  delay(2000);

  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);

  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }

  float hif = dht.computeHeatIndex(f, h);
  float hic = dht.computeHeatIndex(t, h, false);

  Serial.print(F("Humidity: "));
  Serial.print(h);
  Serial.print(F("%  Temperature: "));
  Serial.print(t);
  Serial.print(F("°C "));
  Serial.print(f);
  Serial.print(F("°F  Heat index: "));
  Serial.print(hic);
  Serial.print(F("°C "));
  Serial.print(hif);
  Serial.println(F("°F"));
}

Contributing

If you want to contribute to this project:

  • Report bugs and errors
  • Ask for enhancements
  • Create issues and pull requests
  • Tell others about this library
  • Contribute new protocols

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Credits

The author and maintainer of this library is Adafruit info@adafruit.com

Based on previous work by:

  • T. DiCola
  • P. Y. Dragon
  • L. Fried
  • J. Hoffmann
  • M. Kooijman
  • J. M. Dana
  • S. Conaway
  • S. IJskes
  • T. Forbes
  • B. C
  • T. J Myers
  • L. Sørup
  • per1234
  • O. Duffy
  • matthiasdanner
  • J. Lim
  • G. Ambrozio
  • chelmi
  • adams13x13
  • Spacefish
  • I. Scheller
  • C. Miller
  • 7eggert

License

This library is licensed under MIT license.