#include <dht.h> //add the library for dht
#include <LiquidCrystal_I2C.h> //add the library for LCD
#define dhtPin 8 //define pin 8 as dhtPin
dht sensor; //object for dht commands
LiquidCrystal_I2C screen(0x27, 16, 2); //create an object named screen for the LCD commands
void setup() {
// put your setup code here, to run once:
screen.init(); //start the LCD
screen.clear(); //clear any display
screen.backlight(); //turn on the backlight
}
void loop() {
// put your main code here, to run repeatedly:
int collect = sensor.read11(dhtPin); //initialize the data collection from the pin 8
float temp = sensor.temperature; //collect temperature reading and store it in the temp variable
float humid = sensor.humidity; //collect humidity reading and store it in humid variable
screen.setCursor(0, 0); //set the cursor to display in col 0, row 0
screen.print("TEMP: "); //display the string of characters TEMP:
screen.setCursor(6, 0); //set the cursor to display in col 6, row 0
screen.print(temp); //display the value stored in the temp variable
screen.setCursor(0, 1); //set the cursor to display in col 0, row 1
screen.print("HUMID: "); //display the string of characters TEMP:
screen.setCursor(7, 1); //set the cursor to display in col 7, row 1
screen.print(humid); //display the value stored in the humid variable
delay (2000); //set delay for 2 secs.
screen.clear();