Skip to content

Commit 784a879

Browse files
authoredFeb 25, 2020
Add files via upload
1 parent 02762ff commit 784a879

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
 

‎DHT11_Temp_Humidity.ino

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//This uses a DHT11 temperature and humidity sensor, to measure and print out temperature and relative humidity of the environment the circuit is in
2+
3+
#include <dht.h>
4+
dht DHT;
5+
#define DHT11_PIN 7
6+
7+
void setup(){
8+
Serial.begin(9600);
9+
}
10+
11+
void loop(){
12+
int chk = DHT.read11(DHT11_PIN);
13+
Serial.print("Read sensor: ");
14+
switch (chk)
15+
{
16+
case 0: Serial.println("OK"); break; //if everything is ok
17+
case -1: Serial.println("Checksum error"); break; //if there's a checksum error
18+
case -2: Serial.println("Time out error"); break; //if there's a timeout error
19+
default: Serial.println("Unknown error"); break; //if there's an unknown error
20+
}
21+
22+
Serial.print("Temperature = ");
23+
Serial.println(DHT.temperature);
24+
Serial.print("Humidity = ");
25+
Serial.println(DHT.humidity);
26+
delay(5000);
27+
}

0 commit comments

Comments
 (0)
Please sign in to comment.