-
Notifications
You must be signed in to change notification settings - Fork 0
/
dht.ino
40 lines (35 loc) · 945 Bytes
/
dht.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <DHT.h>;
const int led = 23;
int count = 0;
const int DHTPIN = 22; // 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(115200);
dht.begin();
Serial.println("Test");
}
void loop() {
/*
count++;
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
Serial.println(count);
*/
//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.
}