 #define HEATER_DELTA                        0.0 
 #define WHITE_LED_PIN                        12
 #define BLUE_LED_PIN                         14
-#define SSID                              "XXX"
-#define SSID_PASSWD            "XXXXXXXXXXXXXX"
+#define WATER_LEVEL_PIN                       5
+#define SSID                        "XXX"
+#define SSID_PASSWD      "XXX"
 #define MQTT_SERVER                    "cortex"
 #define MQTT_CLIENT                "TankClient"
-#define TEMP_CAL                          23.80
-#define TEMP_MEASURE                      22.89
+#define TEMP_CAL                          23.00
+#define TEMP_MEASURE                      23.00
 #define TEMP_DELTA    (TEMP_CAL - TEMP_MEASURE)
 
-WiFiClient                        espClient;
-PubSubClient                mqtt(espClient);
-OneWire                 oneWire(DALLAS_PIN);
-DallasTemperature          dallas(&oneWire);
-DeviceAddress                 dallasAddress;
-DHT                  dht(DHT_PIN, DHT_TYPE);
-Ticker                     furtilizerTicker;
-char                               msg[500];
-uint64_t                        counter = 0;
-float                         watertemp = 0;
-float                           airtemp = 0;
-float                          humidity = 0;
-float                        settemp = 23.0;
-bool                       heaterON = false;
+WiFiClient                           espClient;
+PubSubClient                   mqtt(espClient);
+OneWire                    oneWire(DALLAS_PIN);
+DallasTemperature             dallas(&oneWire);
+DeviceAddress                    dallasAddress;
+DHT                     dht(DHT_PIN, DHT_TYPE);
+Ticker                        furtilizerTicker;
+char                                  msg[500];
+uint64_t                           counter = 0;
+float                          watertemp = 0.0;
+float                            airtemp = 0.0;
+float                           humidity = 0.0;
+float                           settemp = 23.0;
+bool                          heaterON = false;
+bool                           waterOK = false;
 
 void setup() {
   Serial.begin(115200);
-  pinMode(     LED_BUILTIN,    OUTPUT  );
-  digitalWrite(LED_BUILTIN,    FALSE   );
-  pinMode(     FURTILIZER_PIN, OUTPUT  );
-  digitalWrite(FURTILIZER_PIN, TRUE    );
-  pinMode(     HEATER_PIN,     OUTPUT  );
-  digitalWrite(HEATER_PIN,     FALSE   );
-  analogWrite( WHITE_LED_PIN,  PWMRANGE);
-  analogWrite( BLUE_LED_PIN,   PWMRANGE);
+  pinMode(     LED_BUILTIN,     OUTPUT      );
+  digitalWrite(LED_BUILTIN,     FALSE       );
+  pinMode(     FURTILIZER_PIN,  OUTPUT      );
+  digitalWrite(FURTILIZER_PIN,  TRUE        );
+  pinMode(     HEATER_PIN,      OUTPUT      );
+  digitalWrite(HEATER_PIN,      FALSE       );
+  analogWrite( WHITE_LED_PIN,   PWMRANGE    );
+  analogWrite( BLUE_LED_PIN,    PWMRANGE    );
+  pinMode(     WATER_LEVEL_PIN, INPUT       ); //Pullup in hardware
   setup_wifi();
   delay(100);
   mqtt.setServer(MQTT_SERVER, 1883);

}

void measure(){
  dallas.requestTemperatures();
  watertemp = dallas.getTempC(dallasAddress);
  airtemp   = dht.readTemperature();
  humidity  = dht.readHumidity();
}

void msgString(float f){

  msgString(humidity);
  mqtt.publish("livingroom/tank/humidity", msg);      
  msgString(float(heaterON));
  mqtt.publish("livingroom/tank/heater", msg);
  msgString(float(waterOK));
  mqtt.publish("livingroom/tank/waterlevel", msg);        
}

void heaterCheck(){
