Created
September 4, 2019 15:38
-
-
Save maipatana/695bd92a8136f72952ff75aba7501d12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "DHT.h" | |
//Constants | |
#define DHTPIN 7 // what pin we're connected to | |
#define DHTTYPE DHT22 // DHT 22 (AM2302) | |
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino | |
//Variables | |
int chk; | |
float hum; //Stores humidity value | |
float temp; //Stores temperature value | |
void setup() | |
{ | |
Serial.begin(9600); | |
dht.begin(); | |
} | |
void loop() | |
{ | |
delay(2000); | |
//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(10000); //Delay 2 sec. | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
code from https://create.arduino.cc/projecthub/mafzal/temperature-monitoring-with-dht22-arduino-15b013 with a very slightly modified when import library