ESP-12E ESP8266 Reed Switch Door sensor help

I found a tutorial on how to make a DIY WiFi Door Sensor.http://www.simpleiothings.com/10-diy-door-sensor/
But I didn't realize (before I started purchasing the items) that the tutorial was outdated
and didn't work or was very buggy at best.

I figured it shouldn't be a problem because surely someone else had made something like this.
I then found this ESP8266 to IFTTT Using Arduino IDE but he was using the ESP with a breadboard and thus wrote the sketch to need a 10k resistor between the IO port and 3.3v.
Does anyone have a sketch that simply calls a IFTTT webhook when a switch is opened or closed using just the GND and one GPIO? The sketch for the ESP8266 to IFTTT Using Arduino IDE works good but I'd prefer to use only 2 pins if possible.

Here is a link to the board I have. V3 Wireless module NodeMcu

Any help or advise is greatly appreciated.

#include <ESP8266WiFi.h>
#include <arduino.h>
#include "DataToMaker.h"

#define SERIAL_DEBUG // Uncomment this to disable serial debugging

// define gpio pins here:
#define NUMBER_OF_SENSORS 1 // THIS MUST MATCH THE NUMBER OF SENSORS IN THE SENSOR ARRAY / NO MORE THAN 3

#define FRONT_DOOR_PIN 5 // GPIO5
// pin for heatbeat LED
#define HEARTBEAT_PIN 13 //GPIO13


// Define program constants

const char* myKey = "mykey"; // your maker key here
const char* ssid = "SSID"; // your router ssid here
const char* password = "WiFiPassword"; // your router password here

// define program values
int sensors[NUMBER_OF_SENSORS] = {FRONT_DOOR_PIN}; // place your defined sensors in the curly braces
String doorStates[2] = {"Closed", "Open"}; // You can change the LOW / HIGH state strings here

// declare new maker event with the name "event"
DataToMaker event(myKey, "event");

// LEAVE SET

int pvsValues[NUMBER_OF_SENSORS];
bool connectedToWiFI = false;

void setup()
{
#ifdef SERIAL_DEBUG
  Serial.begin(115200);
  delay(200);
  Serial.println();
#endif

  delay(10); // short delay
  pinMode(HEARTBEAT_PIN, OUTPUT);
  for (int i = 0 ; i < NUMBER_OF_SENSORS ; i++)
  {
    pinMode(sensors[i], INPUT);
    pvsValues[i] = -1; // initialise previous values to -1 to force initial output
  }
  WiFi.mode(WIFI_STA);
  ConnectWifi();
}

void loop() {
  if (wifiConnected)
  {
    if (DetectChange())
    {
      debugln("connecting...");
      if (event.connect())
      {
        debugln("Connected To Maker");
        event.post();
      }
      else debugln("Failed To Connect To Maker!");
    }
    delay(1000); // pause for 1 second
    digitalWrite(HEARTBEAT_PIN, !digitalRead(HEARTBEAT_PIN));
  }
  else
  {
    delay(60 * 1000); // 1 minute delay before trying to re connect
    ConnectWifi();
  }
}

bool ConnectWifi()
{
  // Connect to WiFi network
  debugln();
  debugln();
  debug("Connecting to ");
  debugln(ssid);
  unsigned long startTime = millis();
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED && startTime + 30 * 1000 >= millis()) {
    delay(500);
    debug(".");
  }
  if (WiFi.status() == WL_CONNECTED)
  {
    debugln("");
    debugln("WiFi connected");
  }
  else
  {
    WiFi.disconnect();
    debugln("");
    debugln("WiFi Timed Out!");
  }
}

bool wifiConnected()
{
  return WiFi.status() == WL_CONNECTED;
}


bool DetectChange()
{
  int val;
  bool changed = false;
  for (int i = 0 ; i < NUMBER_OF_SENSORS ; i++)
  {
    if ((val = digitalRead(sensors[i])) != pvsValues[i])
    {
      pvsValues[i] = val;
      event.setValue(i + 1, doorStates[val]);
      debug("Changes Detected On Value");
      debugln(String(i + 1));
      changed = true;
    }
  }
  if (!changed) debugln("No Changes Detected");
  return changed;
}


void debug(String message)
{
#ifdef SERIAL_DEBUG
  Serial.print(message);
#endif
}

void debugln(String message)
{
#ifdef SERIAL_DEBUG
  Serial.println(message);
#endif
}

void debugln()
{
#ifdef SERIAL_DEBUG
  Serial.println();
#endif
}

The first sketch you quoted http://www.simpleiothings.com/10-diy-door-sensor/ is written to use the ESP8266's LUA interpreter.

The second sketch http://www.instructables.com/id/ESP8266-to-IFTTT-Using-Arduino-IDE/ uses the Arduino core software. The installation of the Arduino Core Software, incidentally, overwrites the standard ESP8266 firmware including the LUA interpreter.

The 10K resistor you mentioned (I couldn't see it anywhere) is almost certainly a standard pullup resistor and is not necessary if you use the 'INPUT_PULLUP' specifier of the pinMode() command. Wiring the sensor between ground and a pin is standard and means that the sensor (switch) is LOW when closed and HIGH when open.

Hi 6v6gt

Thank you very much for the information.

You're correct the 10K resistor is a standard pullup resistor and was only mentioned being needed in the comments below the tutorial for using a 2 wire switch.

I figured it wasn't necessary since it wasn't used in the first tutorial but I know nothing about LUA and so little about Arduino code I didn't know how it was being accomplished.

Again thank you for the info on INPUT_PULLUP I'll give that a try.

That worked perfectly and was so easy to fix the code thanks again 6v6 for that info. Just incase anyone else finds the tutorials mentioned and has problems here is my code.

#include <ESP8266WiFi.h>
#include <arduino.h>
#include "DataToMaker.h"

#define SERIAL_DEBUG // Uncomment this to disable serial debugging

// define gpio pins here:
#define NUMBER_OF_SENSORS 1 // THIS MUST MATCH THE NUMBER OF SENSORS IN THE SENSOR ARRAY / NO MORE THAN 3

#define FRONT_DOOR_PIN 5 // GPIO5

// pin for heatbeat LED
#define HEARTBEAT_PIN 13 //GPIO13


// Define program constants

const char* myKey = "EnterKeyFromIFTTT"; // your maker key here
const char* ssid = "YourSSID"; // your router ssid here
const char* password = "YourPassword"; // your router password here

// define program values
int sensors[NUMBER_OF_SENSORS] = {FRONT_DOOR_PIN}; // place your defined sensors in the curly braces
String doorStates[2] = {"Open", "Closed"}; // You can change the LOW / HIGH state strings here

// declare new maker event with the name "Break_In"
DataToMaker event(myKey, "Door_Alarm");

// LEAVE SET

int pvsValues[NUMBER_OF_SENSORS];
bool connectedToWiFI = false;

void setup()
{
#ifdef SERIAL_DEBUG
  Serial.begin(115200);
  delay(200);
  Serial.println();
#endif

  delay(10); // short delay
  pinMode(HEARTBEAT_PIN, OUTPUT);
  for (int i = 0 ; i < NUMBER_OF_SENSORS ; i++)
  {
    pinMode(sensors[i], INPUT_PULLUP);
    pvsValues[i] = -1; // initialise previous values to -1 to force initial output
  }
  WiFi.mode(WIFI_STA);
  ConnectWifi();
}

void loop() {
  if (wifiConnected)
  {
    if (DetectChange())
    {
      debugln("connecting...");
      if (event.connect())
      {
        debugln("Connected To Maker");
        event.post();
      }
      else debugln("Failed To Connect To Maker!");
    }
    delay(1000); // pause for 1 second
    digitalWrite(HEARTBEAT_PIN, !digitalRead(HEARTBEAT_PIN));
  }
  else
  {
    delay(60 * 1000); // 1 minute delay before trying to re connect
    ConnectWifi();
  }
}

bool ConnectWifi()
{
  // Connect to WiFi network
  debugln();
  debugln();
  debug("Connecting to ");
  debugln(ssid);
  unsigned long startTime = millis();
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED && startTime + 30 * 1000 >= millis()) {
    delay(500);
    debug(".");
  }
  if (WiFi.status() == WL_CONNECTED)
  {
    debugln("");
    debugln("WiFi connected");
  }
  else
  {
    WiFi.disconnect();
    debugln("");
    debugln("WiFi Timed Out!");
  }
}

bool wifiConnected()
{
  return WiFi.status() == WL_CONNECTED;
}


bool DetectChange()
{
  int val;
  bool changed = false;
  for (int i = 0 ; i < NUMBER_OF_SENSORS ; i++)
  {
    if ((val = digitalRead(sensors[i])) != pvsValues[i])
    {
      pvsValues[i] = val;
      event.setValue(i + 1, doorStates[val]);
      debug("Changes Detected On Value");
      debugln(String(i + 1));
      changed = true;
    }
  }
  if (!changed) debugln("No Changes Detected");
  return changed;
}


void debug(String message)
{
#ifdef SERIAL_DEBUG
  Serial.print(message);
#endif
}

void debugln(String message)
{
#ifdef SERIAL_DEBUG
  Serial.println(message);
#endif
}

void debugln()
{
#ifdef SERIAL_DEBUG
  Serial.println();
#endif
}

rmhouttz, any chance you could post a pic of your board so I can see how you have everything connected?. I am looking to complete this project as well. My parts are to arrive tomorrow.
Thanks for your help!