         // The Photon will stay on unless the battery is less than 75% full, or if the pump is running.
         // If the battery is low, it will stay on if we've told it we want to update the firmware, until that times out (updateTimeout)
         // It will stay on no matter what for a time we set, stored in the variable communicationTimeout
+		
+		if (millis() - lastUS > USmeasureTime) { // measure waterHeight more frequently
+            measureUS();
+        }
         if (millis() - lastMeasureTime > measureInterval) {
             doTelemetry();
         }

                System.sleep(SLEEP_MODE_DEEP, wakeUpTimeoutShort);
            }
    }
}

void eventHandler(String event, String data)

float distance;
unsigned long duration;
float waterHeight;
float waterHeightSum;
//################### update these vars ###################
float totalDistance = 64; // the distance from the sensor to the bottom of the water tank
//################### update these vars ###################
unsigned long lastUS = 0;
unsigned long USmeasureTime = 1000; // measure every second

// photocell
float lightIntensity;
