/*
Arduino LCD I2C Testing. Board used is Arduino Uno. DHT sensor used is DHT22, LCD Screen used is 1602 with I2C converter
Inspiration from YouTube channel mentioned below and other sources.
https://www.youtube.com/channel/UCYJa3gs8q49-N3TLm-7ygUw?sub_confirmation=1
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
#include <DHT.h>
#define DHTPIN 2 //Digital Pin 2 of Arduino Uno
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.setCursor(1, 0);
lcd.print("Hello !");
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Welcome to SANSO ");
lcd.setCursor(1, 1);
lcd.print("HYDERABAD LAB");
delay(6000);
lcd.clear();
delay(500);
lcd.noBacklight(); // Turn off the LCD screen backlight
Serial.begin(9600);
dht.begin();
}
void loop()
{
lcd.setCursor(0, 0);
//lcd.print("Wait for T & H");
//delay(3000);
//lcd.clear();
// program for reading temperature and Humidity
float t = dht.readTemperature();
float h = dht.readHumidity();
Serial.print("Temperature:");
lcd.print(" Temp:");
lcd.print(t);
lcd.print(" C");
Serial.print(t);
Serial.print(" C");
//lcd.clear();
//delay(200);
lcd.setCursor(0,1);
Serial.print("Humidity:");
lcd.print("Humidity:");
lcd.print(h);
lcd.print(" %");
Serial.print(h);
Serial.println("%");
delay(500);
}