 void loop() {
   mqtt.check();
   readSensors();
-  delay(15000);
+  delay(10000);
+  //sleep();
 }
 
 void readSensors() {
   float temperature = dhts.temperature();
   float humidity = dhts.humidity();
+  boolean waterPresent = isExposedToWater();
 
   String json = "{";
   json += "\"temperature\": ";
   json += temperature;
   json += ", \"humidity\": ";
   json += humidity;
+  json += ", \"water\": ";
+  json += (waterPresent ? "PRESENT" : "NOT PRESENT");
   json += ", \"door\": \"";
   json += (doorState == LOW ? "OPEN" : "CLOSED");
   json += "\"}";

#define DEVICE_NAME "water_mote_01"
#define MAC_ADDR { 0x90, 0xA2, 0xDA, 0x00, 0x4B, 0x2A }
#define MQTT_SERVER "mqtt.autohome.brule.net"
#define MQTT_USERID "XXXXXX"
#define MQTT_PASSWD "XXXXXX"

byte macAddr[] = MAC_ADDR;
MQTT mqtt(DEVICE_NAME, macAddr, MQTT_SERVER, MQTT_USERID, MQTT_PASSWD);

DHTSensor dhts(DHT_PIN);
int doorState = digitalRead(DOOR_PIN);

boolean startup = true;


  Serial.begin(115200);
  mqtt.setup();
  dhts.setup();
  
  pinMode(DOOR_PIN, INPUT_PULLUP);
  doorState = digitalRead(DOOR_PIN);
  attachInterrupt(digitalPinToInterrupt(DOOR_PIN), doorOpen, CHANGE);

  pinMode(WATER_PIN, INPUT);
  
  delay(1000);
  startup = false;
}
