Hardware components | ||||||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 |
My Project displays the temperature and humidity on an LCD1602 module.
Used: DHT11 (temperature and humidity) sensor (3PIN). It's very simple to build. :)
- LiquidCrystal
Hot to install it:
- Go in Arduino, then Tools -> Manage library -> (and download the needed library)
- Manually Installation: Download for example "Adafruit_Sensor" -> Go into your "Arduino" folder -> then in "libraries" folder and Finally -> Extract your file
[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);
}
Comments
Please log in or sign up to comment.