     //TransmitData(get_temp(), get_hum());
     root["temperature"] = get_temp();
     root["Humidity"] = get_hum();
-    
+    TransmitData();
     task1 = millis();
+  }
+
+  // Sende Messdaten wenn die Oeffnungen offen sind alle 30 Sekunden
+  if(isopen){
+    if((unsigned long)(currmillis - task3) >= 30000){
+      //TransmitData(get_temp(), get_hum());
+      root["temperature"] = get_temp();
+      root["Humidity"] = get_hum();
+      TransmitData();
+      task3 = millis();
+    }
   }
 
   // checke die Luftfeuchtigkeit und wenn zu niedrig schalte Luefter ein.

    while(wifi.available()>0){
      if(wifi.find("STAIP,")){
        delay(1000);
        Serial.println("IP Address;");
        while(wifi.available()>0){
          ch=wifi.read();
          if(ch=='+')

    delay(1000);
  }
  Serial.print(IP);
  Serial.print(F("Port:"));
  Serial.println(80);
}

void wifi_init(){
  connect_wifi(F("AT"),100);
  connect_wifi(F("AT+CWMODE=1"),100);
  connect_wifi(F("AT+CWQAP"),100);
  connect_wifi(F("AT+RST"),5000);
  check_ip(5000);
  if(!NO_IP){
    Serial.println(F("Connecting Wifi..."));
    connect_wifi("AT+CWJAP=\"tlapse\",\"Timelapse-2016\"",7000); //username,password,waittime
  } else {
  }
  Serial.println(F("Wifi Connect"));
  //get_ip();
  connect_wifi(F("AT+CIPMUX=0"),100);
  //connect_wifi(F("AT+CIPSERVER=1,80"),100);
}


void setup() {
  Serial.begin(115200);
  wifi.begin(115200);
  wifi_init();

  root["ID"] = ID;
  root["sendtime"] = stime;
  root["measuretime"] = mtime;

  // We need to attach the servo to the used pin number 
  servo1.attach(servo_pin);
  
  pinMode(servo_pin, OUTPUT);
  digitalWrite(servo_pin, LOW);
  
  dht.setup(dhtPin);
}

unsigned long task1, task2, task3 = 0;
void loop() {
  unsigned long currmillis = millis();

  //falls der Luefter laeuft pruefe alle 15 Sekunden die Werte
  if (isopen) {
    if ((unsigned long)(currmillis - task2) >= 15000) {
      byte i;
