AttachInterrupt fires interrupt

Hi,

I’m using a Photon to count LED pulses on my electric meter using an interrupt. I’m also using a DHT22 to log the temperature every 5 minutes using the PietteTech library which also uses interrupts. I’ve had some problems with instability which I believe is due to my LED counting interrupt disrupting the delicate timings of the DHT22. So I’m removing and adding the interrupt while reading from the DHT22 but I’m then getting the interrupt incorrectly firing straight after attatchInterrupt. Here’s a rough outline of my code.

Do I need to clear waiting interrupts before attaching the interrupt again?

Thanks for any help,
Kev

#include "application.h"
#include "http_client.h"
#include "PietteTech_DHT.h"

#define DHTTYPE DHT22     // Sensor type DHT11/21/22/AM2301/AM2302
#define DHTPIN  D1        // Digital pin for communications
#define UNSET   -100      // A variable that wont be used by power, temperature (i hope), or humidity
#define ENVIORNMENT_INTERVAL  300000 // 5 minutes
#define PUSH_RESULTS_INTERVAL 10000 // 10 seconds
#define LIGHTSENSORPIN  A0

void dht_wrapper(); // must be declared before the lib initialization
bool bDHTstarted;   // flag to indicate we started acquisition
httpClient http;
float temperature = UNSET;
float humidity = UNSET;
volatile int power = UNSET;
volatile unsigned long lastWattUsed = 0;
unsigned long nextEnviornmentReading;
unsigned long nextUpdateTime;

// Lib instantiate
PietteTech_DHT DHT(DHTPIN, DHTTYPE, dht_wrapper);

// This wrapper is in charge of calling
// must be defined like this for the lib work
void dht_wrapper() {
    DHT.isrCallback();
}

void lightSensorISR() {
  unsigned long currenttime = millis();
  if (lastWattUsed > 0)
    power = 3600000 / (currenttime - lastWattUsed);
  lastWattUsed = currenttime;
}

void setup() {
  pinMode(LIGHTSENSORPIN, INPUT);
}

void loop() {
  unsigned long currenttime = millis();

  if (currenttime > nextUpdateTime) {
    if (power != UNSET && temperature != UNSET && humidity != UNSET) {
      http.sendData(power, temperature, humidity);
      nextUpdateTime = currenttime + PUSH_RESULTS_INTERVAL;
    }
  }

  if (currenttime > nextEnviornmentReading) {
    if (!bDHTstarted) {		// start the sample
      detachInterrupt(LIGHTSENSORPIN);
	  DHT.acquire();
	  bDHTstarted = true;
    }

    if (!DHT.acquiring()) {		// has sample completed?
      // get DHT status
      int result = DHT.getStatus();

      if (result == DHTLIB_OK) {
        humidity = DHT.getHumidity();
        temperature = DHT.getCelsius();
      }
      bDHTstarted = false;
      nextEnviornmentReading = currenttime + ENVIORNMENT_INTERVAL;
      lastWattUsed = 0;
      attachInterrupt(LIGHTSENSORPIN, lightSensorISR, FALLING);
    }
  }

  delay(10);
}