How To Getting Temperature And Humidity Sensor (DHT11) Values With Arduino

Required Hardware

For users who do not have Hackerspace Karachi Arduino Kit v1.0

  • Arduino Board
  • Breadboard
  • DHT11
  • Hook-up Wires

Circuit

For users who do not have Hackerspace Karachi Arduino Kit V1.0

Schematic

Code

                    

1. /*
2. Reading values from DHT11 with Arduino
3.
4. This example shows how to Read values from DHT11 using the Arduino.
5.
6. The circuit:
7. – DHT11
8. connected to digital pin of Arduino
9.
10. http://hackerspacekarachi.org/
11. */
12. #include <dht11.h>
13. #define DHT11PIN 7 //connected to digital pin 7
14.
15. dht11 DHT11; //define type
16.
17. void setup()
18. {
19. Serial.begin(9600);// initializing serial
20.
21. }
22.
23. void loop()
24. {
25. Serial.println();
26.
27. int chk = DHT11.read(DHT11PIN); //reading from the sensor
28.
29. Serial.print(“Humidity (%): “); //printing results
30. Serial.println((float)DHT11.humidity, 2);
31.
32. Serial.print(“Temperature (C): “);
33. Serial.println((float)DHT11.temperature, 2);
34.
35. delay(2000);
36.
37. }

1. /*