#include <dht.h>
#define dataPin 8
#include <LiquidCrystal_I2C.h> // add the i2c lcd library
// create an object named display - connect it to the lcd library and set the parameters
//set the i2c address and dimension - 16, 2
LiquidCrystal_I2C display (0x27, 16, 2);
//object
dht sensor;
int tempLED = 5;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(tempLED, OUTPUT);
display.init(); //initiate the LCD
display.clear(); // clear any display text
display.backlight (); // turn on the backlight
}
void loop() {
// put your main code here, to run repeatedly:
int getReading = sensor.read11 (dataPin);
float temp = sensor.temperature;
float humid = sensor.humidity;
display.setCursor (0,0); // column 0, row 0
display.print ("Temperature:"); //display this text
display.setCursor(12, 0); // column 12, row 0
display.print(temp); // display variable value
display.setCursor (0,1); // column 0, row 1
display.print ("Humidity:"); //display this text
display.setCursor(10, 1); // column 10, row 1
display.print(humid); // display variable value
if (temp > 28)
{
digitalWrite(tempLED, HIGH);
delay (1000);
digitalWrite (tempLED, LOW);
delay(1000);
}
else
{
digitalWrite (tempLED, LOW);
}
delay(1000); //delay 1 sec
display.clear(); // clear text
}