#include <LiquidCrystal_I2C.h>
#include "Adafruit_HTU21DF.h"
int sensorPin = A1;    // select the input pin for the potentiometer
float sensorValue = 0;  // variable to store the value coming from the sensor
float co2=0;
float temp=0;
float rel_hum =0;

LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
Adafruit_HTU21DF htu = Adafruit_HTU21DF();

void setup() {
  // put your setup code here, to run once:
  lcd.init();
  lcd.backlight(); //turn on backlight
}

String line1;
String line2;
int loopTime = 3000;

void loop() {
  // put your main code here, to run repeatedly:
    sensorValue = analogRead(sensorPin);
    co2=sensorValue*5.0/1023*500;
    temp = htu.readTemperature();
    rel_hum = htu.readHumidity();
    line1=String(String(temp)+" C; "+String(rel_hum)+"%");
    line2=String(String(co2)+" ppm");

  lcd.setCursor(0, 0); // set the cursor to column 0, line 0
  lcd.print(line1);

  lcd.setCursor(0, 1); // set the cursor to column 0, line 1  
  lcd.print(line2);
  delay(loopTime);
  lcd.clear();

}
