An Arduino library for the DHT series of low-cost temperature/humidity sensors.
You can find DHT11 and DHT22 tutorials here.
To use this library:
=================================
Sample DHT11...
Sample OK: 19 *C, 31 H
=================================
Sample DHT11...
Sample OK: 19 *C, 31 H
=================================
Remark: For DHT11, no more than 1 Hz sampling rate (once every second). Remark: For DHT22, no more than 0.5 Hz sampling rate (once every 2 seconds).
Simple C++ code with lots of comments.
Strictly follow the standard DHT protocol.
Support 0.5HZ(DHT22) or 1HZ(DHT11) sampling rate.
SimpleDHT sensor library is compatible with multiple low-cost temperatures and humidity sensors like DHT11 and DHT22. A few examples are implemented just to demonstrate how to modify the code for different sensors.
DHT sensor library is open-source and uses one of the most permissive licenses so you can use it on any project.
This library including the following examples:
One of the SimpleDHT examples is the following:
#include <SimpleDHT.h>
int pinDHT22 = 2;
SimpleDHT22 dht22(pinDHT22);
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.println("=================================");
Serial.println("Sample DHT22...");
byte temperature = 0;
byte humidity = 0;
int err = SimpleDHTErrSuccess;
if ((err = dht22.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
Serial.print("Read DHT22 failed, err="); Serial.print(SimpleDHTErrCode(err));
Serial.print(","); Serial.println(SimpleDHTErrDuration(err)); delay(2000);
return;
}
Serial.print("Sample OK: ");
Serial.print((int)temperature); Serial.print(" *C, ");
Serial.print((int)humidity); Serial.println(" RH%");
delay(2500);
}
Winlin 2016.1
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 Winlin winlin@vip.126.com.
Based on previous work by:
This library is licensed under MIT.