HilfePlus
Published © GPL3+

Temperature and Humidity (LCD | DHT11)

Display for DHT11 (temperature and humidity). Temperature: Grad Celsius and Fahrenheit (possible).

BeginnerFull instructions provided17,078
Temperature and Humidity (LCD | DHT11)

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
--> Optional <--
×1

Story

Read more

Schematics

Build

Temperature and Humidity

Code

[ENG] Code (Fahrenheit) with Serial Monitor

C/C++
For DHT11 with LCD Display (Fahrenheit) and with Serial Monitor
/*
-------------------------------------------------------------------------------------------
- Library required:                                                                       -
- "LiquidCrystal", "DHT_sensor_library" and "Adafruit_Sensor-master"                      -
- Download: Adafruit_Sensor-master on Github: https://github.com/adafruit/Adafruit_Sensor -
- Put it in your Arduiono dictory "libraries"                                             -
- License: GNU General Public License version 3 or later (GPL3+)                          -
- By HilfePlus                                                                            -
-------------------------------------------------------------------------------------------
*/

// --Library-- / Bibliotheken
  #include <LiquidCrystal.h>
  #include <DHT.h>
  #include <DHT_U.h>
  
// Sensor DHT-11 (DHT-11 Temperature and Humidity Sensor)
  #define DHTPIN 8
  #define DHTTYPE DHT11

// LCD Display (PIN)(LCD1602 Module)
  LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  DHT dht(DHTPIN, DHTTYPE);


void setup() {
// Serial Monitor
  Serial.begin(9600);

// LCD Display
  lcd.begin(16, 2);
  lcd.setCursor(7,1);
  lcd.print("By Hilfe+");
  dht.begin();
  
// LCD Display (Temp and Humidity)
  lcd.setCursor(0,0);
  lcd.print("Temp:");
  lcd.setCursor(0,1);
  lcd.print("Humid:");
  delay(1500);
  }


void loop() {
  lcd.setCursor(12,1);
  lcd.print("%");
// Load (Arrow)
  delay(550);
  lcd.setCursor(13,0);
  lcd.print("<");
  delay(50);
  lcd.setCursor(14,0);
  lcd.print("-");
  delay(50);
  lcd.setCursor(15,0);
  lcd.print("-");
  delay(50);
  lcd.setCursor(15,1);
  lcd.print("-");
  delay(50);
  lcd.setCursor(14,1);
  lcd.print("-");
  delay(50);
  lcd.setCursor(13,1);
  lcd.print("<");

// ...
  lcd.setCursor(12,0);
  lcd.print(" ");
  
// -- Temp and Humidity --
// Temp = Temperature in Fahrenheit and Humid = Humidity
    float f = dht.readHumidity();
    float c = dht.readTemperature(true);

  // Sensor Error (For Example No Sensor)
    if (isnan(f) && (c)) {
      lcd.clear();
      lcd.setCursor(4,1);
      lcd.print("|SENSOR|");
      lcd.setCursor(4,0);
      lcd.print("|ERROR |");  
      delay(1000);
      return;
      }
  
// LCD Display (values)
  lcd.setCursor(7,0);
  lcd.print(c);
  lcd.setCursor(7,1);
  lcd.print(f);

// Serial Monitor
  Serial.println("-  Result  -");
  Serial.print("Temp:  "); 
  Serial.println(c);
  Serial.print("Humid: ");
  Serial.println(f);
  Serial.println("- - -  - - -");
  Serial.println(" ");
  Serial.println(" ");
  
// Ende (Arrow)
  delay(400);
  lcd.setCursor(15,1);
  lcd.print(" ");
  delay(50);
  lcd.setCursor(14,1);
  lcd.print(" ");
  delay(50);
  lcd.setCursor(13,1);
  lcd.print(" ");
  delay(50);
  lcd.setCursor(13,0);
  lcd.print(" ");
  delay(50);
  lcd.setCursor(14,0);
  lcd.print(" ");
  delay(50);
  lcd.setCursor(15,0);
  lcd.print(" ");
  delay(50);
}

[GER] Code (Grad Celsius) with Serial Monitor

C/C++
For DHT11 with LCD Display (Grad Celsius) and with Serial Monitor
/*
-------------------------------------------------------------------------------------------
- Library required:                                                                       -
- "LiquidCrystal", "DHT_sensor_library" and "Adafruit_Sensor-master"                      -
- Download: Adafruit_Sensor-master on Github: https://github.com/adafruit/Adafruit_Sensor -
- Put it in your Arduiono dictory "libraries"                                             -
- License: GNU General Public License version 3 or later (GPL3+)                          -
- By HilfePlus                                                                            -
-------------------------------------------------------------------------------------------
*/

// Library / Bibliotheken
  #include <LiquidCrystal.h>
  #include "DHT.h"
  #include <DHT_U.h>

// Sensor DHT11 (DHT11 Temperature and Humidity Sensor)
  #define DHTPIN 8
  #define DHTTYPE DHT11

// LCD Display (PIN)(LCD1602 Module)
  LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  DHT dht(DHTPIN, DHTTYPE);

void setup() {
// Serial Monitor
  Serial.begin(9600);
  
// LCD Display
  lcd.begin(16, 2);
  lcd.setCursor(7,1);
  lcd.print("By Hilfe+");
  
// LCD Display (Temp and Humidity) (Temperatur und Luftfeuchtigkeit)
  dht.begin();
  lcd.setCursor(0,0);
  lcd.print("Temp:");
  lcd.setCursor(0,1);
  lcd.print("Humid:");
  delay(1500);
  }


void loop() {  
  lcd.setCursor(12,1);
  lcd.print("%");
// Load (Arrow)
  delay(250);
  lcd.setCursor(13,0);
  lcd.print("<");
  delay(50);
  lcd.setCursor(14,0);
  lcd.print("-");
  delay(50);
  lcd.setCursor(15,0);
  lcd.print("-");
  delay(50);
  lcd.setCursor(15,1);
  lcd.print("-");
  delay(50);
  lcd.setCursor(14,1);
  lcd.print("-");
  delay(50);
  lcd.setCursor(13,1);
  lcd.print("<");

// ...
  lcd.setCursor(12,0);
  lcd.print(" ");
  lcd.setCursor(12,1);
  lcd.print(" ");
  
// --Temp and Humidity-- (Temperatur und Luftfeuchtigkeit)
// Temp = Temperature in Grad Celsius
// Humid = Humidity (Luftfeuchtigkeit)
    float f = dht.readHumidity();
    float c = dht.readTemperature();

  // Sensor Error (For Example No Sensor)(Zum Beispiel keinen Sensor)
    if (isnan(f) && (c)) {
      lcd.clear();
      lcd.setCursor(4,1);
      lcd.print("|SENSOR|");
      lcd.setCursor(4,0);
      lcd.print("|ERROR |");  
      delay(1000);
      return;
      }

// LCD Display (values)(Ergebnisse)
  lcd.setCursor(7,0);
  lcd.print(c);
  lcd.setCursor(7,1);
  lcd.print(f);

// Serial Monitor
  Serial.println("-  Result  -");
  Serial.print("Temp:  "); 
  Serial.println(c);
  Serial.print("Humid: ");
  Serial.println(f);
  Serial.println("- - -  - - -");
  Serial.println(" ");
  Serial.println(" ");
  
// Ende (Arrow)(Pfeil)
  delay(400);
  lcd.setCursor(15,1);
  lcd.print(" ");
  delay(50);
  lcd.setCursor(14,1);
  lcd.print(" ");
  delay(50);
  lcd.setCursor(13,1);
  lcd.print(" ");
  delay(50);
  lcd.setCursor(13,0);
  lcd.print(" ");
  delay(50);
  lcd.setCursor(14,0);
  lcd.print(" ");
  delay(50);
  lcd.setCursor(15,0);
  lcd.print(" ");
  delay(50);
}

Credits

HilfePlus
0 projects • 3 followers
Contact

Comments

Please log in or sign up to comment.