FloKra d9e47579fd 0.5.0 2020-01-09 | преди 4 години | |
---|---|---|
.. | ||
.github | преди 4 години | |
examples | преди 4 години | |
.gitignore | преди 4 години | |
.travis.yml | преди 4 години | |
CONTRIBUTING.md | преди 4 години | |
DHT.cpp | преди 4 години | |
DHT.h | преди 4 години | |
README.md | преди 4 години | |
keywords.txt | преди 4 години | |
library.properties | преди 4 години |
An Arduino library for the DHT series of low-cost temperature/humidity sensors.
You can find DHT tutorials here.
This library depends on Adafruit Unified Sensor Library. To use this library the user must download the required library.
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.
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.
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.
The library is free, you don’t 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 you’ll encourage the development of the library, but you’ll also learn how to best use the library and probably some C++ too
DHT sensor library is open-source and uses one of the most permissive licenses so you can use it on any project.
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"));
}
If you want to contribute to this project:
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
The author and maintainer of this library is Adafruit info@adafruit.com
Based on previous work by:
This library is licensed under MIT license.