Search code examples
network-programmingarduinonat

Set up Arduino to connect remotely


I have a Arduino connected to my home network using an Ethernet shield. I can control the board using simple URL request (e.g. 192.168.2.1/digitaloutput/8/1, turn pin 8 high etc.). I can only do that when connected to my home network.

What do I need to do connect to it remotely, say from my work computer? Is it possible to use the same method I am currently using (Arduino acting as a web server)?


Solution

  • The network address you show is a "private" address, allocated by your router. On the global internet these addresses are "not routable", which means no-one else can get to your 192.168.2.1 (because there are lots of other copies of that address behind other home routers, and there would be no way to know which one to use). You need to find the public IP address of your router, and then use port-forwarding to redirect a port on your router to your Arduino. This is the easiest method to do what you want, but also the least secure.

    You'd be able to say something like http:<router-address>/digitaloutput/8/1 from your work computer and your router would forward the HTTP request on to your Arduino. Of course, anyone else in the world will be able to do that as well. A hint: there's no requirement that HTTP be served from the standard port 80.