#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27
#define LCD_COLUMNS 20
#define LCD_LINES 4
//LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
LiquidCrystal_I2C lcd(I2C_ADDR,LCD_COLUMNS,LCD_LINES);
// Pin DHT 11
#define DHT_PIN 2
#define DHT_TYPE DHT22
#define sensorMIN 0
#define sensorMAX 512
#define Threshold 300
DHT dht(DHT_PIN,DHT_TYPE);
int value = 0 ; //Isi nilai sensor
int level = 0 ; //nilai level
void setup() {
// put your setup code here, to run once:
lcd.init();
lcd.backlight();
Serial.begin(9600);
dht.begin();
lcd.setCursor(6,0);
lcd.print("Welcome");
lcd.setCursor(2,1);
lcd.print("TEMPT. & HUMIDITY");
delay(4000);
lcd.clear();
}
void loop() {
// put your main code here, to run repeatedly:
delay(1000);
//START
value = analogRead(DHT_PIN);
digitalWrite(DHT_PIN, LOW);
delay(1000);
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
Serial.print("TEMPERATURE DETECTED: ");
Serial.print(temperature);
Serial.print(" HUMIDITY: ");
Serial.println(humidity);
lcd.setCursor(0, 0);
lcd.print("TEMPERATURE: ");
lcd.setCursor(13, 0);
lcd.print(temperature);
lcd.setCursor(0,1);
lcd.print("HUMIDITY : ");
lcd.setCursor(13, 1);
lcd.print(humidity);
}