 }
 
 void setup() {
-  Serial.begin(115200);
-  Serial.println("starting");
-
-  pinMode(RX_IR_PIN, INPUT);
+  pinMode(RX_IR_PIN, INPUT_PULLUP);
   attachInterrupt(digitalPinToInterrupt(RX_IR_PIN),&handleInterrupt,CHANGE);
 
     // turn of the Access Point as we are not using it


  // make sure we are good for wifi
  if (WiFi.status() != WL_CONNECTED) {
    Serial.print("Connecting to ");
    Serial.println(ssid);
    WiFi.reconnect();

    if (WiFi.waitForConnectResult() != WL_CONNECTED) {
      Serial.println("Failed to reconnect WIFI");
      Serial.println(WiFi.waitForConnectResult());
      delay(100);
      return;
    }
  }

  if (!client.connected()) {
    Serial.println("PubSub not connected");
    String clientId = String(IR_TOPIC) + String("IR_Receiver");
    if (client.connect(clientId.c_str())) {
      Serial.println("PubSub connected");
      //client.subscribe(LED_TOPIC);
    } else {
      Serial.println("PubSub failed to connect");
    }
  }


PubSubClient client(mqttServerString, mqttServerPort, callback, wclient);

ICACHE_RAM_ATTR void handleInterrupt() {
  // validate that we have actually changed state
  int lastValue = globalCurrentValue;
  globalCurrentValue = digitalRead(RX_IR_PIN);
  if (lastValue == globalCurrentValue) {
    // value has not changed so don't do anything
    return;
  };

  unsigned long timeMicros = micros();
  unsigned long duration = timeMicros - globalLastInterruptTime;
  globalEntries[globalCurrentEntry] = duration;
  globalCurrentEntry++;
  globalLastInterruptTime = timeMicros;
