How To LCD With DHT11

Required Hardware

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

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

Circuit

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

Schematic

Code

                    

1. /*
2. LCD with DHT11
3.
4. This example shows how to use LCD with DHT11.
5.
6. The circuit:
7. – LCD
8. SDA connected to analog pin A4.
9. SCL connected to analog pin A5.
10.
11. – DHT11
12. connected to digital pin of Arduino
13.
14. http://hackerspacekarachi.org/
15. */
16. //Library version:1.1
17. #include <Wire.h>
18. #include <LiquidCrystal_I2C.h>
19. #include <dht11.h>
20. #define DHT11PIN 7 //connected to digital pin 7
21.
22. LiquidCrystal_I2C lcd(0x27, 20, 4); // set the LCD address to 0x27 for a 16 chars and 2
line display
23.
24. dht11 DHT11; //define type
25.
26. void setup()
27. {
28. lcd.init(); // initialize the lcd
29. lcd.init();
30. lcd.backlight();
31. }
32.
33. void loop()
34. {
35. int chk = DHT11.read(DHT11PIN); //reading from the sensor
36. lcd.setCursor (0, 0);
37. lcd.print(“Humidity (%): “); //printing results
38. lcd.setCursor (14, 0);
39. lcd.print((float)DHT11.humidity, 2);
40. lcd.setCursor (0, 1);
41. lcd.print(“Temp (C): “);
42. lcd.setCursor (10, 1);
43. lcd.print((float)DHT11.temperature, 2);
44.
45. delay(2000);
46.
47. }

1. /*