MARUF Mmimb
MARUF Mmimb

Reputation: 1

Internet connection problem from different network for NodeMCU ESP8266 which I am using for IOT home automation

Would anyone like to help me with this problem please?

how to connect/control Nodemcu esp8266 wi-fi module from different network for control iot devices from outside of any home/ house?

Internet connection problem from different network for NodeMCU ESP8266 which I am using for IOT home automation.

Actually, in case of an class project, I have used some code (also coppied some code and took help from some website) from internet and also used Blynk for controll my ESP8266. But not i want to make a personal app by which app I can control my devices outside from my home.

I have already connected with my WI-FI router with my home network!! It worked well, But i don't know how to do the same thing from different netwrok.

If possible I think anyone can help me....

Thank you. To everyone.

Upvotes: 0

Views: 1150

Answers (2)

priyank goriya
priyank goriya

Reputation: 56

You can use Arduino IDE to program ESP8266 device.

https://randomnerdtutorials.com/how-to-install-esp8266-board-arduino-ide/

After installing ESP8266 in Arduino IDE. You need to connect ESP8266 with WiFi router(which have internet connected). Once your device is connected with a WiFi router. you can MQTT protocol to communicate with the server. You can use the following library in Arduino to implement MQTT client in ESP8266. ESP8266 is used to send and receive data from a different network. ESP8266 is subscribed to a particular topic. You can publish data to that topic from different MQTT client.

https://github.com/Imroy/pubsubclient

Use the Following link to get more familiar with MQTT protocol

https://www.hivemq.com/blog/mqtt-essentials-part-1-introducing-mqtt

You can use MQTTfx desktop application to send and receive data from NodeMcu(ESP8266).

MQTT basic diagram for understanding

Upvotes: 0

MBer
MBer

Reputation: 2524

This has been answered in greater detail on both the Arduino and Internet of Things StackExchange sites. In summary:

For safety, it is difficult to start a connection to a device on another local network. Devices on WiFi networks are protected from the Internet by a firewall, which is normally configured to return responses to requests sent by the devices, but block all unsolicited messages. Even if the firewall allows an incoming connection on a given port, "port forwarding" or other custom configurations are needed for unexpected messages to reach one of the multiple devices on the network (the devices usually share the same public IP address of the network and external systems' messages cannot reach the right local address without forwarding by the router).

Any device exposed to unsolicited requests like this is at risk of being attacked and can pose a risk to other systems on the network. It is thus safer to leave the firewall the same and instead make the device subscribe to an external webserver, which acts as a mailbox for incoming messages. Then, you can send requests to the server from anything with an internet connection, and the server will store them and relay them to the ESP8266 whenever the ESP asks. MQTT protocol using a server-side broker program like Mosquitto and a client like PubSubClient on your ESP8266 could work for this sort of publish-subscribe model, and MQTT tutorials and explanations are available both on both tool sites and Stack sites.

Upvotes: 0

Related Questions