File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments