       else
         sleepInterval = 60 * 15;
       nextSleepTime = millis() + (sleepInterval * 1000) + WAKE_INTERVAL;
-      executeRequest(PH_ADDRESS,"Sleep");
+      executeRequest(PH_ADDRESS,"Sleep"); 
       executeRequest(ORP_ADDRESS,"Sleep");
       digitalWrite(POWER, LOW);
-      System.sleep(SLEEP_MODE_DEEP,sleepInterval);
+      System.sleep(SLEEP_MODE_DEEP, sleepInterval);
+    } else {
+      nextSleepTime = millis() + SAMPLE_INTERVAL;
+      orp = ph = 0;
     }
   }
 }
 
 String water_data() {
-  return String::format("{\"temperature\":%f,\"ph\":%f,\"orp\":%f,\"soc\":%f,\"wifi\":%d}",temp,ph,orp,soc,wifi);
-}
-
-int measure(String arg) {
-  ph = 0;
-  orp = 0;
-  temp = 0;
-  measure_temp();
-  measure_ph();
-  measure_orp();
-  measure_wifi();
+  if(temponly)
+    return String::format("{\"temperature\":%f,\"soc\":%f,\"wifi\":%d}",temp,soc,wifi);
+  else 
+    return String::format("{\"temperature\":%f,\"ph\":%f,\"orp\":%f,\"soc\":%f,\"wifi\":%d}",temp,ph,orp,soc,wifi);
 }
 
 void measure_ph() {

  //Serial.print("Ph:");
  //Particle.publish("ph_reading", pH_data, PRIVATE);
  //Serial.println(pH_data);
  if (isdigit(pH_data[0])) {
    float current = String(pH_data).toFloat();
    if(ph == 0)
      ph = current;
    else
      ph = (ph + current) / 2;

double soc = 0;
int wifi;
bool calibrationmode = false;
bool temponly = false;

void setup() {
  if (!Wire.isEnabled())
    Wire.begin();

  pinMode(POWER,OUTPUT);
  pinMode(TEMP_SENSOR, INPUT);
  pinMode(CALIBRATION_LED, OUTPUT);
  digitalWrite(POWER, HIGH);
  digitalWrite(CALIBRATION_LED, LOW);

  lipo.begin();
  lipo.quickStart();
