Arduino UNO - LCD display and DHT11 sensor with temperarure and humidity measurement. When there is no datafrom the DHT11 sensor, the buzzer will be activated.

requirements:

- Arduino UNO
- 100 Ohm resistor
- Potentionmeter 10K Ohm
- LCD 1602 module
- Buzzer 5v
- DHT11 temperature and humidity sensor
- Breadboard

LCD connection:



DHT11 Sensor Connection:

Buzzer connection:

Arduino pin 2 ---> 100 Ohm resistor ---> + buzzer ---> - buzzer --- GND

#include <LiquidCrystal.h> //library
#include <SimpleDHT.h> //library
int DHT11pin = 2; //DHT PIN
int buzzer = 3; // 5V Buzzer
SimpleDHT11 dht11;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); //LCD pins

void setup() {
  Serial.begin(9600);
  pinMode(buzzer, OUTPUT); //set buzzer pinmode
  lcd.begin(16, 2); //set lcd to 16 positions and 2 rows
}

void loop() {
  // read with raw sample data.
  byte temperature = 0;
  byte humidity = 0;
  byte data[40] = {0};
  // Show error when DHT11 reading fails
  if (dht11.read(DHT11pin, &temperature, &humidity, data)) {
    lcd.setCursor(0,0);
    lcd.print("DHT11           ");
    lcd.setCursor(0,1);
    lcd.print("ERROR           ");
 // Error sound from Buzzer
  tone(buzzer, 1000);
  delay(1500);
  noTone(buzzer);
  delay(500);
  tone(buzzer, 1500);
  delay(1000);
  noTone(buzzer);
  delay(1000);
  return;
  //
  //LCD print
  }
 //clear screen
  lcd.setCursor(0, 0);
 //print text
  lcd.print("Temp:     C  ");
 //set cursor to position 6 first row
  lcd.setCursor(6,0);
 //print temperature data
  lcd.print(temperature);
 //set cursor to second row  
  lcd.setCursor(0,1);
 //print text
  lcd.print("Hum:      %  ");
 //set cursor to position 6 second row
  lcd.setCursor(6,1);
 //print humidity data 
  lcd.print(humidity);
 //Wait 2 seconds to read new data
    delay(2000);
  }