Skip to content

Instantly share code, notes, and snippets.

@winhtut
Last active August 2, 2019 15:43
Show Gist options
  • Save winhtut/b26979d6ecf28906c5427754071e1220 to your computer and use it in GitHub Desktop.
Save winhtut/b26979d6ecf28906c5427754071e1220 to your computer and use it in GitHub Desktop.
//library link https://www.arduinolibraries.info/libraries/simple-dht
#include <DHT.h>;
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
float hum;
float temp;
void setup()
{
Serial.begin(9600);
dht.begin();
Serial.println("Welcome to Green Hackers");
}
void loop()
{
hum = dht.readHumidity();
temp= dht.readTemperature();
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment