Skip to content
intermediate 45 minSensorDisplay

Room Weather Station

Read temperature and humidity with a DHT11 and show them on a 16x2 LCD that updates every two seconds.

This project joins a sensor and a display over two different interfaces: the DHT11 talks on a single data pin, and the LCD uses I2C, which needs only two wires for the whole screen.

Build it

  1. 1

    Install the libraries

    In the Arduino IDE, open the Library Manager and install 'DHT sensor library' and 'LiquidCrystal I2C'.

  2. 2

    Wire the DHT11

    VCC to 5V, GND to GND and Data to pin 2.

  3. 3

    Wire the LCD

    VCC to 5V, GND to GND, SDA to A4 and SCL to A5.

  4. 4

    Upload

    Upload the sketch. If the screen is blank, turn the blue contrast dial on the back of the LCD.

The code

room-weather-station-lcd.ino
#include <DHT.h>
#include <LiquidCrystal_I2C.h>

DHT dht(2, DHT11);
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  dht.begin();
  lcd.init();
  lcd.backlight();
}

void loop() {
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(dht.readTemperature(), 1);
  lcd.print(" C  ");
  lcd.setCursor(0, 1);
  lcd.print("Hum:  ");
  lcd.print(dht.readHumidity(), 0);
  lcd.print(" %  ");
  delay(2000);
}