 // This #include statement was automatically added by the Spark IDE.
 #include "HTU21D/HTU21D.h"
 
-int ledSampling = D2; // use led for now, but this is RS232 comms LED.
-//int clockSpeed = CLOCK_SPEED_400KHZ;
-
-// Loop counter 
-int loopCounter = 0;
+int ledSampling = D2; 
+int fanPulseIn = D4; // Max pin for Core intterupt
+int fanControl  = D7; 
 
 // Temperature and humidity
 HTU21D humiditySensor;

    
    digitalWrite(ledSampling, HIGH);
    RGB.color(0, 0, 125);
    Spark.publish("Reading", "Reading...");
    delay(100);
    
    readHumidity();
    readTemperature();
    
    delay(100);
    RGB.color(0, 0, 0);
    digitalWrite(ledSampling, LOW);
    loopCounter = 0;
    
    delay(2000);
     
     // Do not use Sleep as it breaks Photon WiFi!
    // Can we put the Core into low power mode?
    // Photon:
    //System.sleep(2);
    // Core:
    // Spark.sleep(1);
    delay(2000);
} 

void readHumidity() {

    // Initialize Temperature and humidity
    if (!humiditySensor.begin()) {
        RGB.color(255, 0, 00);
        Spark.publish("Status", "Humidity Sensor setup failed.");
    }
    
    //delay(1000);
    Spark.publish("Status", "Setup complete.");
    RGB.color(0, 0, 0);
    delay(2000);
}
