 
   // 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

void door_open() {

  // turn on wifi if we aren't connected
  if(WiFi.status() != WL_CONNECTED)
    wifi_init();

  // grab the door feed
  Adafruit_IO_Feed door = aio.getFeed("door");

  // send door open value to AIO
  door.send("1");


void wifi_init() {

  // wifi init
  Serial.println("Starting WiFi");
  WiFi.begin(WLAN_SSID, WLAN_PASS);

  // wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    Serial.write('.');
    delay(500);
  }

  // AIO init
  Serial.println("Connecting to Adafruit.io");
  aio.begin();

}
