 
   // if door isn't open, we don't need to send anything
   if(digitalRead(DOOR) == LOW) {
-    // sleep a bit before checking again
-    ESP.deepSleep(SLEEP_LENGTH * 1000000, WAKE_RF_DISABLED);
-    return;
+    Serial.println("Door closed");
+    // we don't do anything
+  } else {
+    // the door is open if we have reached here,
+    // so we should send a value to Adafruit IO.
+    Serial.println("Door is open!");
+    door_open();
   }
 
-  // the door is open if we have reached here,
-  // so we should send a value to Adafruit IO.
-  door_open();
-
   // we are done here. go back to sleep.
+  Serial.println("zzzz");
   ESP.deepSleep(SLEEP_LENGTH * 1000000, WAKE_RF_DISABLED);
-
 }
 
 // noop

Adafruit_IO_Client aio = Adafruit_IO_Client(client, AIO_KEY);

void setup() {

  EEPROM.begin(512);
  pinMode(DOOR, INPUT_PULLUP);



  // send battery level to AIO
  battery.send(level);
}
