logo elektroda
logo elektroda
X
logo elektroda

Controlling ESP32 from outside the network - how to configure access?

madiz08 3063 5
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18009394
    madiz08
    Level 14  
    Hello,
    I'm using an ESP32 to control and transfer data over my home WiFi. Perhaps the question is not for this section, but could I get at least some links to topics on how to control the ESP32 output when I am at work. From the few examples I've done (phone app - ESP32), from the phone app, I'm streaming the internal IP address 192.168.0.106/on. This of course only works over local wifi. I realise that my phone at work connecting over mobile internet has a completely different IP and doesn't know how to connect to my router at home, which goes out to the world with yet another IP.
    In order to write something like this, should I go back to acquiring knowledge from computer networks, or are there any ready-made or links on how I can do this
  • ADVERTISEMENT
  • ADVERTISEMENT
  • Helpful post
    #3 18009568
    kaczakat
    Level 34  
    Depending on whether your IP is fixed or variable, but external at all, you can approach the subject in different ways. In either case, you need to have access to your router settings and know how to forward ports. For example, you redirect port 12222 to the internal IP 192.168.0.106 and port 80 (typically for a web server). If the external IP is fixed then you specify IP:12222/on in your command. If the IP is changeable, you will need to set up a DDNS client in the router, check which services it can handle, enter the service, create an account, register a free name and as a result, whenever the router is in the network, no matter what its IP is, you will be able to access it using that name, e.g. wolnanazwa.ddns.net:12222/On - you probably do not use Polish characters.
    If you don't have an external IP, you are left with installing Blynk or a similar system and relying on the available solutions via intermediary servers. On the other hand, it may be safer this way - opening and forwarding the port is a certain probability that someone else will also want to use it.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #4 18009679
    madiz08
    Level 14  
    I see, which means I will try via blynk first.
  • ADVERTISEMENT
  • Helpful post
    #5 18021773
    Maciej_1985
    Level 2  
    Hey,
    I am developing a platform called remoteme.org, maybe it will help you to achieve this in an easy way - compared to blynk you have full freedom in creation, because you simply create web pages and using libraries you communicate with ESP, and then such a page can be exported with a few clicks as an app on your phone:
    https://remoteme.org/pl/wysylanie-push-notyfi...likacji-na-androidzie-out-of-the-box-project/
    here I have described step by step and probably exactly what you need (and there is no need for router configuration, fixed IP or other such - it works out of the box ;) )
  • #6 18028650
    madiz08
    Level 14  
    Blynk tested and works fine, but has limitations.
    As a second step, I would like to try to connect via an open port. The first thing I did was configure port forwarding on my TP-Link router:
    Controlling ESP32 from outside the network - how to configure access? .
    I then found out my IP address to the world via whatsmyip. Wanting to send a command via the browser, in the windows firewall settings I added a rule to allow port 350.
    I typed the command XXX.XX.XXX.X:350/zone1_ON, where normally 192.168.0.106/zone1_ON activates my ESP32 output and nothing. I set that IP address on the app on the phone (I have an editableIP address there) and nothing either.
    It turned out to be something I had completely forgotten about. After typing the IP address from whatsmyip into the browser, it turned out that a page with the configuration of the second router popped up. The LIVEBOX router is connected to the world, my TPLINK router is connected to it via LAN:
    Controlling ESP32 from outside the network - how to configure access? .
    Now for this to work I suspect I would also have to open a port on the LIVEBOX, is that right? Or would it be enough to change the gateway on the ESP32 to 192.168.1.1?
    I also have a question about security, when I configure a PORT for a specific IP, do I make sure I'm only allowing something from the outside to that specific device IP address, or am I opening access to everything?
    How is my TP-LINK router seen by the LIVEBOX router? Is it also assigned an IP from the 192.168.1.XXX group?
    I'm very interested in testing this, but I'm a bit afraid of over-combining.
    I'm also still wondering if the ESP32 in the arduino program should not have a particular port configured.

    Added after 27 [minutes]: .

    I have now noticed that colleague cachat has already written about the information that the internal port should be set to 80, I will change that too.
ADVERTISEMENT