-1

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?

3
  • please explain "mobile WiFi", I suspect you are referring to whats aka mobile internet, 3G/4G, LTE and so on.
    – MatsK
    Sep 3 '17 at 9:08
  • Yes i want to connect nodemcu to mobile internet
    – Mayur
    Sep 3 '17 at 14:36
  • NodeMcu is made specially for wireless communication. You can connect it to wifi and hospot. You just need to pull in some library and pass you data to connect. Sep 3 '17 at 14:48
2

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.)

3
  • SIM800 is 2G = low bandwidth
    – MatsK
    Sep 3 '17 at 9:03
  • I don't think switching lights will need a lot of bandwidth though. Sep 3 '17 at 11:43
  • I agree, it shouldn't.
    – MatsK
    Sep 3 '17 at 11:48
1

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.

3
  • Can u provide link for wifi library
    – Mayur
    Sep 4 '17 at 14:53
  • The library is built in. Check in the list of library. Sketch > Include Library > ESP8266WiFi Sep 4 '17 at 14:59
  • @Mayur did that work? Sep 4 '17 at 16:17
0

You don't need an external router or LAN to connect nodeMCU with Android or any other TCP/IP device. nodeMCU is capable of works as a WiFi access point, among other things.

You use he function wifi.setmode() to configure the WiFi mode to use. NodeMCU can run in one of four WiFi modes:

  1. Station mode, where the NodeMCU device joins an existing network.
  2. Access point (AP) mode, where it creates its own network that others can join.
  3. Station + AP mode, where it both creates its own network while at the same time being joined to another existing network
  4. WiFi off

When using the combined Station + AP mode, the same channel will be used for both networks as the radio can only listen on a single channel.

Now, to connect to Internet you will need something else. You can use a SIM800/SIM900 module, which let you conect your nodeMCU to Internet and send/receive SMS.

In this scenario, nodeMCU will connect directly to Internet for your remote connections, and will also works as WiFi router for local connections.

Keep in mind that nodeMCU is a lightweight router.

3
  • I Dont want to use gsm here is their any other option im using Android application to control relay i want to connect nodemcu to internet so that the signal from app can be accessible from anywhere can u tell me how to connect it with webserver
    – Mayur
    Sep 3 '17 at 14:42
  • Can u tell me the way without using gsm to connect it to internet and send and receive signal over it
    – Mayur
    Sep 3 '17 at 14:47
  • The viable solutions is GSM/3G/4G or WiFi. Satellite is a bit outside my knowledge.
    – MatsK
    Sep 3 '17 at 14:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.