 const int delayTillAlarm = 100;
 void waterReadings();
 
+//Heartbeat global variables
+const unsigned int heartbeatTimeout = 5000;
+int heartbeat(bool sent = false);
+
 void setup() {
 
   //Setup LED

  static unsigned int timeSinceLastHigh = 0; //time since the last high reading
  static bool activated = false; //has the high readings been around long enough that it warranted an alarm
  static unsigned long lastSignal = 0; //time the last warning signal was sent
  
  // if a water reading is made
  if (digitalRead (sensorPin) == LOW) {
    timeSinceLastHigh = millis(); //a high water reading was made, reset the counter
    
    //if there has been one seen previously
    if (noticed) {
      
      //and it's been around for a while without getting turned off, activate
      if (millis() - timeNoticed >= delayTillAlarm && activated == false) {
        bluetooth.write('1');
        activated = true;
        lastSignal = millis();
      }
      
      //if the alarm has already been activated, wait for the first alarm to play so you don't flood the alarm beacon
      if (activated && millis() - lastSignal >= 1200) {
        bluetooth.write('1');
        lastSignal = millis();
      }
      
    }
    else { //this is the first time it's been seen, make note of it
      noticed = true;
      timeNoticed = millis();
    }
    
  }
  else { //there is no more high water readings
    
    //if the high water readings have been away for a while, kill the alarm
    if (noticed && millis() - timeSinceLastHigh > timeTillOff) {
      noticed = false;
      activated = false;
    }
    
  }
}

bool reconfiguration() {
  Serial.println ("Starting reconfiguration...");
  bool retVal = false;
  unsigned int counter = 0;
  
  delay(10); //Necessary to make this work
  
  while (Serial.available() && counter < 2) {
    char input = Serial.read();
    
    if (input == ' ' && counter == 0) {
      //NULL, keep going
    }
    else if (input == '0' && counter == 1) {
      opMode = sensor;
      blinkRate = sensorBlinkRate;
      EEPROM.write(eepromModeAddress, 0);
      retVal = true;
      Serial.println("Now a sensor. Reconfiguration successful.");
    }
    else if (input == '1' && counter == 1) {
      opMode = alarm;
      blinkRate = alarmBlinkRate;
      EEPROM.write(eepromModeAddress, 1);
      retVal = true;
      Serial.println("Now an alarm. Reconfiguration successful.");
    }
    else if (input == '2' && counter == 1) {
      
      if (opMode == sensor) {
        Serial.println("I'm a sensor.");
        retVal = true;

      blinkRate = 0;
    }
  }

  //oscillate light
  if (millis() - time >= blinkRate) {
    statePin = !statePin;
