#include <LiquidCrystal_I2C.h>
#include <dht.h>
#define dataPin 8 //Defines pin number to which the sensor is connected
dht Sensor; //create an object named Sensor to access the functions in dht lib
LiquidCrystal_I2C screen(0x27,16,2); //this creates an object named screen asc. w/ the lcd lib
void setup()
{
screen.init(); //initialize the LCD
screen.clear(); //clear the display
screen.backlight(); //turn on the backlight
}
void loop()
{
int readData = Sensor.read22(dataPin); //initialize the collection of reading from the dataPin
float t = Sensor.temperature; //Gets the value of the temperature and store it in t float variable
float h = Sensor.humidity; //Gets the value of the humidity & store it in the h float variable
//printing the results on the serial monitor
screen.setCursor(0,0);
screen.print("Temp= ");
screen.print(t,1);
screen.println(" C");
screen.setCursor(0,1);
screen.print("Humid= ");
screen.print(h,1);
screen.println(" % ");
delay(2000); //Delays 2 seconds
}