
In this tutorial we will see how to read the temperature measured by the DTH11 sensor and display it on an LCD display.
For the DTH11 sensor, we connect:
For the LCD display we connect:
the SDA pin at the Arduino analog pin A4.
the SCL pin at the Arduino analog pin A5.
the VCC pin at the Arduino 5v pin.
the GND pin at the Arduino GND pin
Here is the program that reads the temperature measured by the DTH11 sensor and displays it on an LCD display.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#include <dht11.h> #include <LiquidCrystal_I2C.h> #define DHT11PIN 2 // broche DATA -> PIN 2 LiquidCrystal_I2C lcd(0x27, 20, 4); dht11 DHT11; void setup() { lcd.init(); } void loop() { DHT11.read(DHT11PIN); lcd.backlight(); lcd.clear(); lcd.setCursor(0, 0); lcd.print("temperature= "); lcd.setCursor(0,1); lcd.print((float)DHT11.temperature); delay(2000); } |
Note: you must import the two libraries DTH11 and I2c_LCD1602