Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* DHT11/ DHT22 Sensor Temperature and Humidity Tutorial
- * Program made by Dejan Nedelkovski,
- * www.HowToMechatronics.com
- */
- /*
- * You can find the DHT Library from Arduino official website
- * https://playground.arduino.cc/Main/DHTLib
- */
- #include "DHT.h"
- #define DHTPIN 2
- #define DHTTYPE DHT22
- DHT dht(DHTPIN, DHTTYPE);
- //Variables
- int chk;
- float hum; //Stores humidity value
- float temp; //Stores temperature value
- void setup()
- {
- Serial.begin(9600);
- dht.begin();
- }
- void loop()
- {
- //Read data and store it to variables hum and temp
- hum = dht.readHumidity();
- temp= dht.readTemperature();
- //Print temp and humidity values to serial monitor
- Serial.print("Humidity: ");
- Serial.print(hum);
- Serial.print(" %, Temp: ");
- Serial.print(temp);
- Serial.println(" Celsius");
- delay(2000); //Delay 2 sec
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement