EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: bodzio_stawski on July 07, 2023, 10:12:53 am

Title: Connection to ESP32 using a device outside the local network
Post by: bodzio_stawski on July 07, 2023, 10:12:53 am
Hello

I am interesting in the topic of connection of ESP32 based device to the WAN. I have home internet and several devices working in the local network. An ESP32 device would be one of them, however, I would like to be able to connect to this device from outside the home.

However, I would like only me and the other person (only two of us) to have access to this device from the outside, and in practice this means that only two particular smartphones would really be able to connect to this device if we were away from home and home network. Any other device should be rejected immediately if it tries to connect to our ESP32.

Is there any possible solution that would not introduce additional financial costs?

Title: Re: Connection to ESP32 using a device outside the local network
Post by: Berni on July 07, 2023, 10:22:37 am
You need to set up a VPN (Virtual Private Network) connection into your LAN.

This way you can install a free open source VPN client on your phone that routes all of the phones internet traffic trough a VPN tunnel. The other end of the tunnel connects to a VPN server on your LAN. This server is listening for outside connections on WAN, authenticates with a key, then opens up the other end of the tunnel, letting the traffic from the VPN client spill out into the LAN.

This way you can connect to it from anywhere on the internet and your phone will look like it is connected to your own LAN directly over WiFi.

If you have a good feature rich router in your LAN then in a lot of cases the VPN server can run inside the router with 0 extra hardware required. Otherwise you can use a Raspberry Pi to serve as a VPN server.

More feature rich routers also support scripting, so in that case you could also do it without a VPN. Just make a script in the router that listens for a key on a certain WAN port, once it sees the key it starts forwarding traffic to the ESP for X minutes.
Title: Re: Connection to ESP32 using a device outside the local network
Post by: liaifat85 on July 08, 2023, 07:31:06 am
Use BLYNK 2 app. For using BLYNK, your ESP8266 should be connected to a wifi network. But with this app, you can monitor and control your ESP8266 from wherever you are. You can switch any load connected to it. You can also read any sensor data connected to the ESP8266. Yeah, initially at the time of pairing the ESP to the mobile phone( where the BLYNK app is installed), they must be close to each other. But after that, you can control you ESP with your mobile phone from anywhere in the world. There is a free version of BLYNK 2.
Title: Re: Connection to ESP32 using a device outside the local network
Post by: bodzio_stawski on July 09, 2023, 09:45:11 pm
Thanks for both answers! I really need to learn about VPN tunneling. Thank you again