user32196: Guys i have done project home automation over Android in which i have use NodeMCU and relay to control switching of lights but this is a offline project.
Now I want to connect it with internet please tell me if I can connect NodeMCU to mobile WiFi.
I don't have router at home  please tell me if it is possible and how?

user37863: I have a wifi library.This is how I connect the NodeMCU with that library.
#include <ESP8266WiFi.h>

#define WIFI_SSID "name_of_your_hotspot"
#define WIFI_PASSWORD "password_of_hotspot"

void setup() {
   Serial.begin(9600);
   WiFi.begin( WIFI_SSID,  WIFI_PASSWORD) ;

    Serial.print("connecting");

    while (WiFi.status() != WL_CONNECTED ) {
        Serial.print(".");
        delay(500);
    }

     Serial.println();
     Serial.print("connected");
     Serial.println(WiFi.localIP);
}

void loop () {
    // Your code
}

I used this tested and working code. Comment if any issue.
Make sure you import the library.
Hope this fixed your issue.
EDIT : 4th Jan 2018
I know this topic is old and maybe the OP solved this problem but I saw many people struggling with this same situation how to connect nodeMCU to an internet connection.
So, I created a medium post with detailed information on how to Connect ESP8266 module to the internet? You can read the story here (I am not paid or sponsored by this post I made this story to help the newbies)
If you still have any problem comment down below or add a response in my medium story.

user20513: If you have a mobile wifi router, the nodemcu can connect to it just as it would connect to a fixed router.
If you want to connect the nodemcu to the internet without a mobile wifi router, you can use a gsm/gprs/3G/4G module, for example the SIM800L. (Provided the location has cell coverage.)

32196: <p>Guys i have done project home automation over Android in which i have use NodeMCU and relay to control switching of lights but this is a offline project.</p>

<p>Now I want to connect it with internet please tell me if I can connect NodeMCU to mobile WiFi.</p>

<p>I don't have router at home  please tell me if it is possible and how?</p>
 37863: <p>I have a wifi library.This is how I connect the NodeMCU with that library.</p>

<pre><code>#include &lt;ESP8266WiFi.h&gt;

#define WIFI_SSID "name_of_your_hotspot"
#define WIFI_PASSWORD "password_of_hotspot"

void setup() {
   Serial.begin(9600);
   WiFi.begin( WIFI_SSID,  WIFI_PASSWORD) ;

    Serial.print("connecting");

    while (WiFi.status() != WL_CONNECTED ) {
        Serial.print(".");
        delay(500);
    }

     Serial.println();
     Serial.print("connected");
     Serial.println(WiFi.localIP);
}

void loop () {
    // Your code
}
</code></pre>

<p>I used this tested and working code. Comment if any issue.</p>

<p>Make sure you import the library.</p>

<p>Hope this fixed your issue.</p>

<p><strong><em>EDIT : 4th Jan 2018</em></strong></p>

<p>I know this topic is old and maybe the OP solved this problem but I saw many people struggling with this same situation how to connect nodeMCU to an internet connection.</p>

<p>So, I created a medium post with detailed information on how to Connect ESP8266 module to the internet? You can read the <a href="https://medium.com/@raajnadar/connect-esp8266-module-to-internet-81cab724b8c3" rel="nofollow noreferrer">story here</a> (I am not paid or sponsored by this post I made this story to help the newbies)</p>

<p>If you still have any problem comment down below or add a response in my medium story.</p>
 20513: <p>If you have a mobile wifi router, the nodemcu can connect to it just as it would connect to a fixed router.
If you want to connect the nodemcu to the internet without a mobile wifi router, you can use a gsm/gprs/3G/4G module, for example the SIM800L. (Provided the location has cell coverage.)</p>
