 // specfic DHT22 unit on your board
 const float temperatureCoef = 1;
 
-float dhtTemperature = 0;
-float dhtHumidity = 0;
-float dsTemperature = 0;
+//Configure I2C sensor for light
+const int sensorBH1750 = 0x23;
 
 // For random generation of MQTT client ID
 static const char alphanum[] ="0123456789"
                               "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                               "abcdefghijklmnopqrstuvwxyz";
 
+String txtTemperature = "";
+String txtHumidity = "";
+String txtWater="";
+String txtLight = "";
+
 void drawDisplay(const char *line1, const char *line2 = "", const char *line3 = "")
 {
-    // Write on OLED display
-    // Clear the internal memory
-    u8g2.clearBuffer();
-    // Set appropriate font
-    u8g2.setFont(u8g2_font_ncenR14_tr);
-    u8g2.drawStr(0,14, line1);
-    u8g2.drawStr(0,39, line2);
-    u8g2.drawStr(0,64, line3);
-    // Transfer internal memory to the display
-    u8g2.sendBuffer();
-}
-
-void connectWiFi() {
-
+  // Write on OLED display
+  // Clear the internal memory
+  u8g2.clearBuffer();
+  // Set appropriate font
+  u8g2.setFont(u8g2_font_ncenR14_tr);
+  u8g2.drawStr(0,14, line1);
+  u8g2.drawStr(0,39, line2);
+  u8g2.drawStr(0,64, line3);
+  // Transfer internal memory to the display
+  u8g2.sendBuffer();
+}
+
+void connectWiFi()
+{
   delay(10);
   // We start by connecting to a WiFi network
   Serial.println();

#define ONE_WIRE_BUS 12
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

// Configure pins
const int pinAlarm = 16;
const int pinButton = 0;

// Configure the interval in milliseconds to read data
// from the sensors and to publish it to thingspeak.com

  }
}

bool isSensorAvailable(int sensorAddress)
{
  // Check if I2C sensor is present
  Wire.beginTransmission(sensorAddress);
  return 0 == Wire.endTransmission();
}

void sensorWriteData(int i2cAddress, uint8_t data)
{
  Wire.beginTransmission(i2cAddress);
  Wire.write(data);
  Wire.endTransmission();
}

String readLight()
{
  // Power on sensor
  sensorWriteData(sensorBH1750, 0x01);
  // Set mode continuously high resolution mode
  sensorWriteData(sensorBH1750, 0x10);

  uint16_t tempAmbientLight;

  Wire.requestFrom(sensorBH1750, 2);
  tempAmbientLight = Wire.read();
  tempAmbientLight <<= 8;
  tempAmbientLight |= Wire.read();
  // s. page 7 of datasheet for calculation
  tempAmbientLight = tempAmbientLight/1.2;

  char convert[80];
  sprintf(convert, "%u", tempAmbientLight);
  return String(convert);
}

void mqttpublish(String temperature, String humidity, String water, String light)
{
  // Create data string to send to ThingSpeak
  String data = String("field1=" + temperature + "&field2=" + humidity + "&field3=" + water + "&field4=" + light);
  int length = data.length();
  char msgBuffer[length];
  data.toCharArray(msgBuffer,length+1);
