#include <dht.h>
#include <LiquidCrystal_I2C.h>

#define DHT22_PIN 2

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

void setup() {
  Serial.begin(115200);
  lcd.init();
  lcd.backlight();
  Serial.println("DHT22 with LCD Demo");
  Serial.println();
}

void loop() {
  char tBuffer[8];
  char hBuffer[8];
  char lBuffer[16];
  char sBuffer[16];

  int chk = DHT.read22(DHT22_PIN);
  dtostrf(DHT.temperature, 5, 1, tBuffer);
  dtostrf(DHT.humidity, 3, 0, hBuffer);
  snprintf(lBuffer, 16, "Temp : %s%cC ", tBuffer, char(223));
  snprintf(sBuffer, 16, "Temp : %s%cC ", tBuffer, char(176));
  Serial.print(sBuffer);
  lcd.setCursor(0, 0);
  lcd.print(lBuffer);
  snprintf(lBuffer, 16, "Humid: %s%% rh ", hBuffer);
  snprintf(sBuffer, 16, "Humidity: %s%% rh ", hBuffer);
  Serial.print(" \t");
  Serial.println(sBuffer);
  lcd.setCursor(0, 1);
  lcd.print(lBuffer);
  delay(2000);
}