 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;

        // 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() - lastMeasureTime > measureInterval) {
            doTelemetry();
        }

    Particle.publish(eventPrefix + "/waterTankSensor/online", "true");
    
    // water height
    ThingSpeak.setField(1, waterHeight);
	
	Particle.publish(eventPrefix + "/waterTankSensor/waterHeight", String(waterHeight));
