please anyone can tell me how can I establish a connection between an ESP based socket server and a mobile when I’m outside wifi coverage (i.e. by 4G data network)?
I’m building some simple remote switches conceptually similar to “Web Server with Slider Switch” you explain in your”MicroPython_Programming_with_ESP32_and_ESP8266_V1_2″ and I need to extend its range outside my home.
I have some devices which do this: e.g. an intercom which is usually connected via Ethernet or wifi home network transmitting messages and video when someone rings the bell. It keeps working when I’m not in my home wifi coverage area but I can’t understand how the smartphone can reach the intercom address which has a private address and is NATted by the router. Maybe it uses an external known server as a bridge?
Thanks for any hint about this.
Hello Enzo, are you familiar with router port forwarding? The following quick guide might help:
That would be the easiest way to make your web servers available from anywhere (without any extra hardware).
Thanks Rui, but I need the link between the smartphone and the ESP based devices could be done without any operation on the software/hardware. I cited my intercom just because of its plug and play working, just giving it access to my home wifi made it communicate inside and outside my home network.
I guess the only chance is something like Firebase, any better idea?
But do you want to access your ESP32 from anywhere? Where is your ESP32 connected to (to your router)?
The ESP8266 is connected to my home wifi as my family smartphones are. It’s all ok until we stay at home and ESP8266 and smartphones are in the wifi coverage area. Of course when the smartphones get out they aren’t connected to the home network anymore. I guess there’s no way to reach the ESP if it hasn’t a public IP or by addressing the router public IP and forwarding the packets to the ESP.
If you know something easier than Firebase or similar (or a server of mine hosted somewhere which performs a similar role) please let me know.
Thanks for making it clear! Exactly, there are a many options that will work for you.
- Open a port in your router, it’s known as “router port forwarding” and your ESP Web Server will be available from anywhere. You basically run a web server with your ESP and you configure your router to allow remote access to your ESP IP address and Port number
- You can use a different device like a Raspberry Pi or a computer with ngrok.com installed. Ngrok will open a secure tunnel to your local network and make your ESP accessible from anywhere.
- Firebase is also a great option, but I don’t have any tutorials on that subject at the moment (we’ll work on it in the future)
- You can also run a Cloud Node-RED dashboard and your ESP32 is connected to it using MQTT. Cloud Node-RED Dashboard or ESP32 Cloud MQTT
- You can also run a website with PHP + MySQL, but it requires a bit more knowledge. I have a few guides that might help.
- ESP32 Weather Station
- Control ESP32 GPIOs from anywhere
- View Sensor Readings from anywhere
- ESP32 MySQL Basics
- ESP32 PHP Email
- ESP32 SIM800L
I hope that helps!