Connect NodeMCU ESP-12E to WiFi Router using Arduino IDE

Connecting the ESP-12E to your Router

Like everything else,  learning to use your ESP-12E is best done in chunks.  In this chunk, you will learn to connect to your WiFi Router.   Its easy and more importantly,  a necessary component to creating IoT objects.  If you can’t connect to your router,  you aren’t connecting to the internet (and that of course is the whole point).

This tutorial assumes that you have already configured your NodeMCU ESP-12E to work with the Arduino IDE.  If not,  read the getting started guide found HERE.

Getting a NodeMCU

If you don’t already have one, you will want to purchase a NodeMCU development board.
Amazon      eBay      Bang Good      Deal Extreme

Arduino IDE ESP8266 NodeMCU Router Connection Tutorial

Get your Routers SSID and Password

Your router will likely have a label on it that indicates your SSID and password.  You will need these for this tutorial to work.   The label may look something like the picture below.

Connect you ESP-12E to your Computer

The power from your USB cable should be enough to connect your device.  If not, you will want to select another means of powering up your NodeMCU.   There is an article showing the different ways to power your NodeMCU HERE.


Copy, Paste and Upload the Tutorial Sketch

afdsf

 

// Henry's Bench
//Checking to ensure you can connect ESP-12E to a router
     
    #include <ESP8266WiFi.h>
     
    const char* ssid     = "YOUR ROUTER SSID";
    const char* password = "YOUR PASSORD";     

    int wifiStatus;
     
    void setup() {
      
      Serial.begin(115200);\
      delay(200);
      
     
     
      // We start by connecting to a WiFi network
     
      Serial.println();
      Serial.println();
      Serial.print("Your are connecting to;");
      Serial.println(ssid);
      
      WiFi.begin(ssid, password);
      
      while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
      }
     
 }   
     
void loop() {
      wifiStatus = WiFi.status();

      if(wifiStatus == WL_CONNECTED){
         Serial.println("");
         Serial.println("Your ESP is connected!");  
         Serial.println("Your IP address is: ");
         Serial.println(WiFi.localIP());  
      }
      else{
        Serial.println("");
        Serial.println("WiFi not connected");
      }
      delay(1000); // check for connection every once a second

}

Verify The Output on the Serial Monitor

Open your serial monitor.  Your output should look like the picture below: