Approching ESP-module from outside my wifi-netwerk

Hello, I’ve been busy managing to be able to control my light from my bedroom over wifi using an ESP8226 module. The code on the arduino toggles the state of the relais when the ESP module acting as a server gets a request.
So a made a page view-source:http://www.kljzomergem.be/esptry.html to send requests to the module wich has IP adress: 192.168.0.212. It’s works when i’m connected to the wifi but when I’m using mobile internet on my smartphone the module doesn’t get requests.

Could anyone help me?

Thanks in advance!

~Sven

Your problem is that incoming IP traffic will be blocked by your router. If you connect your smartphone to the local WiFi it will work. If you connect it through GPRS/GSM etc. it will be regarded as external traffic and will fail.

If you really want external web traffic to connect to internal devices in your network, you will have to set up port forwarding on your router. There are also many good reasons why you should not do this.

You can't have a web server behind NAT, you need to enable port forwarding. But I wouldn't recommend it, the Internet is a dangerous place ...

Why would you use mobile data when you're at home? I'd just connect to the same WiFi network, and keep it safe.

Pieter

Okay that makes sense! Thank you guys! and Pieter: the mobile data was for testing purposes. In later projects I would like to control devices from school/work on my smartphone.

You can avoid port forwarding by using a different architecture. Some internet service providers make a web server and database available or similar ready made services. You issue commands to this server from your smartphone and the commands are put into a database. Your ESP module, now configured as a web client, polls the web server to see if there are any waiting commands (e.g. switch on bedroom light) and executes them.

Yes, I was also thinking in using the module as a web client. I do not actually understand the part about my ISP but i figured that I might try to host a page that holds instructions and download that page with my ESP and search the content for instructions (or in my case wanted light-status).

I do encounter some problems in downloading the webpage as you can see here: https://forum.arduino.cc/index.php?action=profile;area=showposts;u=778421

Thanks for the reply 6v6gt!

6v6gt: You can avoid port forwarding by using a different architecture. Some internet service providers make a web server and database available or similar ready made services.

I don't think Comcast has this service.

What other options would you suggest?

Check out: http://www.blynk.cc/

There are many providers offering Apache Web Server, PHP Server side scripting and MySQL database. Some even claim to be free. However, there is a bit of learning to do if you are not familiar with these products. There are also alternatives which do more or less the same thing eg allowing you to create a web page to store parameters in a database and another to retrieve them.

You may even be able to 'bend' some of the solutions which are foreseen for data logging type applications e.g. Thingspeak or sparkfun's 'Phant' so that you can dump data (eg bedroom light state = ON") and read back the last entry using the ESP8266 web client.