 }
 
 // read soil sensor data
+byte readSoilSensor1() {
+  unsigned int currentSoil1 = readSoilSensor(soilSensor1);
+  int soilDiff = currentSoil1 - soil1;
+  soil1 = (currentSoil1 + soil1) / 2;
+
+  if (soilDiff > 100) {
+    return 1; // indicate soil increase above threshold
+  } else if (soilDiff < 100){
+    return 2; // indicate soil decrease above threshold
+  } else {
+    return 0; // indicate normal reading
+  }
+}
+
 int readSoilSensor(int soilSensor) {
     unsigned int val = 0;
     digitalWrite(led, HIGH);

}

void loop() {
    int sensorStatus = 1;
    if (lastMeasurement > MEASUREMENT_RATE) {
      // read sensor data
      sensorStatus = readSensorData();
      if (sensorStatus >= 0) {
          lastMeasurement = 0;
          postToParticle(sensorStatus); // always publish event

Phant phant(server, publicKey, privateKey);

// interval counters for measurement and post
const int MEASUREMENT_RATE = 15000; // read sensor data every 30 sec
const int POST_RATE = 15 * 60000; // post data every 15 minutes
elapsedMillis lastMeasurement;
elapsedMillis lastPost;
