Esp8266 control from anywhere

I am trying to bulid a iot app to control led through relay using esp8266.It work very well if app is connected to same network as esp is connected, if it out of range then it is not working. I need esp to work even with mobile network so any suggestion to make app to control esp with mobile network from anywhere.

Thnks for suggestion.

Read about MQTT. Here you have a very cool mqtt client extension for appinventor.

In addition, the mqtt library on ESP and will work whenever the phone and esp have internet access on any network. You still need an external server called mqtt broker. You will find free.



In order to connect ESP8266 with MIT app inventor and that too from anywhere, I would suggest you MQTT like Patryk_F has suggested. You can try this tutorial, which do the same thing that you need.

Control ESP8266 from anywhere using MQTT MIT app inventor