 }
 
 // read soil sensor data
-int readSoilSensor(int soilSensor, int &soilValue) {
+int readSoilSensor(const int soilSensor, const int soilSensorPower, int &soilValue) {
     digitalWrite(led, HIGH);
-    digitalWrite(soilPower, HIGH); //turn sensor power on
+    digitalWrite(soilSensorPower, HIGH); //turn sensor power on
     delay(10); // give some time to settle
     soilValue = analogRead(soilSensor);
-    digitalWrite(soilPower, LOW); //turn sensor power off
+    digitalWrite(soilSensorPower, LOW); //turn sensor power off
     delay(190);
     digitalWrite(led, LOW);
 

    lastSensorStatus = currentSensorStatus;
}

int postToParticle() {
  sprintf(publishString,"{\"status\": %d, \"temp\": %0.2f, \"pressure\": %0.2f, \"humidity\": %0.2f, \"soil1\": %u, \"soil2\": %u, \"soil3\": %u}",
    currentSensorStatus, temperature, pressure, humidity, soil1, soil2, soil3);
  Particle.publish("sensor",publishString);
  return 1;
}

int postToPhant() {
  // add variables
  phant.add("status", currentSensorStatus);
  phant.add("temp", temperature, 2);
  phant.add("pressure", pressure, 2);

elapsedMillis lastMeasurement;
elapsedMillis lastPost;

void setup() {
  Serial.begin(9600);

  pinMode(led, OUTPUT);
  for (unsigned int i = 0; i < sizeof(soilSensors); i++) {
    pinMode(soilSensors[i].sensor, INPUT);
    pinMode(soilSensors[i].power, OUTPUT);
  }

  if (!bme.begin()) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
