 
 void stateWorking()
 {
-  celsius(tempSensorValue);
+  
+  writeTempAndHumToLcd();
 
   if (!hatchOpen && (tempSensorValue >= alertLevel ||( humSensorValue >= humLevel && tempSensorValue >= 20))){
-    Serial.print("Alert! over ");
-    Serial.print(alertLevel);
-    Serial.print("degrees, open hatch\n");
+    //Serial.print("Alert! over ");
+    //Serial.print(alertLevel);
+    //Serial.print("degrees, open hatch\n");
     turnServo(90);
     hatchOpen=true;
   }
-  if (hatchOpen && tempSensorValue <= alertLevel-2 && (humSensorValue <= humLevel) || tempSensorValue <= 20){
-    Serial.print("Alert! less than ");
-    Serial.print(alertLevel);
-    Serial.print("(");
-    Serial.print(tempSensorValue);
-    Serial.print(") degrees, close hatch\n");
+  if (hatchOpen && ((tempSensorValue <= alertLevel-2 && humSensorValue <= humLevel) || tempSensorValue <= 20)){
+    //Serial.print("Alert! less than ");
+    //Serial.print(alertLevel);
+    //Serial.print("(");
+    //Serial.print(tempSensorValue);
+    //Serial.print(") degrees, close hatch\n");
     turnServo(180);
     hatchOpen=false;
   }  
 }
 
-void celsius(float deg_cels) {
+void writeTempAndHumToLcd() {
   lcd.setCursor(0,0);
-  int temp = (int)deg_cels; // Convert to C
+  int temp = (int)tempSensorValue;
   lcd.print(temp);
   lcd.write(B11011111); // Degree symbol
   lcd.print("C ");

        }
    }
    else{
      Serial.println("sending data failed...");
    }
  }else{
    Serial.println("D'OH! Connection failure!");
    setupWifi();
  }
  //esp seems wery slow at times, so just in case...
  delay(500);
}

void homepage(uint8_t ch_id) {
  //create dynamic content first, so that we get the length.
  String tempstr = "<p>L&auml;mp&ouml;tila:";
  tempstr += tempSensorValue;
  tempstr += "&deg;C</p>\r\n";
  String humstr = "<p>Kosteus:";
  humstr += humSensorValue;
  humstr += "&#37;</p>\r\n";
  String windowstr = "<p><b>Ikkuna on ";
  windowstr += ((hatchOpen)?"Auki</b></p>\r\n":"Kiinni</b></p>\r\n");
  //count dynamic lengts together and Set Content Len in header
  String hdrContLen = "Content-Length: ";
  hdrContLen += String((tempstr.length() +

byte state = STATE_INITIAL;

//analog pin assignments
const byte tempPotPin    = 0;
const byte humPotPin     = 1;

