#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

#include <dhtnew.h>

#include <DHT.h>
#include <DHT_U.h>


#define DHTPIN 22     // what pin we're connected to

#define DHTTYPE DHT22   

DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup(void) {
  lcd.begin();
  lcd.print("Reading sensor");
  dht.begin();
}

void loop() {
  
  float temperature, humidity;

  humidity = dht.readHumidity();
  temperature = dht.readTemperature();
  delay(2000); 

 lcd.clear();

 char tempF[6]; 
 char humF[6];
 dtostrf(temperature, 5, 1, tempF);
 dtostrf(humidity, 2, 0, humF);

 lcd.print("Temp.:"); 
 lcd.print(tempF);
 // lcd.print((char)223);
 lcd.print(" C");
 lcd.setCursor(0,1);
 lcd.print("Humi.: ");
 lcd.print(humF);
 lcd.print(" %");
 delay(2000);
}
Categories: ArduinoLCDTechnology

Leave a Reply

Your email address will not be published. Required fields are marked *