learning Arduino for beginners EP#21 DHT11 and DHT22 temp and humidity sensor

In this episode we will take a look at how you can use the dht11 or dht22 temperature and humidity sensor with your Arduino board..

 

 

 

ARDUINO Code:

#include <SimpleDHT.h>
#define pinDHT11 6 //data pin
SimpleDHT11 dht11;

void setup() {
Serial.begin(9600);

}

void loop() {
byte temperature = 0;
byte humidity = 0;
dht11.read(pinDHT11, &temperature, &humidity, NULL);
int temperature2 = (temperature * 1.8 + 32);
Serial.print(“temperature = “);
Serial.print(temperature);
Serial.println(“C”);
Serial.print(“temperature = “);
Serial.print(temperature2);
Serial.println(“F”);
Serial.print(“humidity = “);
Serial.print(humidity);
Serial.println(“%”);
delay(1000);
}

Advertisements