Loading, please wait...

DHT-11 with Arduino UNO

Aug 11, 2018 DHT-11, Arduino, IoT, Arduino UNO, 331 Views
DHT-11 is temperature and humidity sensor which returns real time temperature and humidity of the environment.

 

#include "DHT.h"
#define DHTPIN 2 // what digital pin we're connected to
#define DHTTYPE DHT11   // DHT 11
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println("DHT11 Test!");
  dht.begin();
}

void loop() {  
  delay(2000); // Wait a few seconds between measurements.
  float h = dht.readHumidity();  //read humidity
  float t = dht.readTemperature();  //read temperature
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.println(" *C ");
}