   int pushButtonState = HIGH;
   if(pushButtonState == LOW) {
     // button was pressed, connect for an immediate readout
+    Particle.connect();
+    // turn off the LED in case it was on
+    digitalWrite(D7, LOW);
     buttonPressed = true;
     photonState = PHOTON_CONNECTING;
-    Particle.connect();
     return;
   }
   else {

void setup() {
  pinMode(photoPin, INPUT);     // prepare the photoresistor
  pinMode(powerPin, OUTPUT);
  digitalWrite(powerPin, HIGH);
}


      // also publish daily max and min values when button pressed
      (button ? ", lmin: " + slmin + ", lmax: " + slmax : "") +
      "}";
  // publish data: ttl = 60 for now, in the future it may be readoutTimeIntervalMins*60
  if(!Particle.publish("luxdata", payload, PRIVATE, WITH_ACK)) {
    return -1;
  }
