In the past we used this technique to connect and Android app to the arduino Yun over the internet. Our project does this part in a different way yet, but maybe it can be of your interest for other purposes. The Arduino Yun can be accessed without effort when we are on the same network. We only need to know the IP direction of the arduino YUN. But if we are not on the same network, for example, when we are not at home, then we can not connect with our yun.
To provide remote access to our yun, we need the following:
- The external IP of our home router.
- configure our router to forward all the requests made to the external ip, port 80 (htttp) to our arduino, inside our home network.
- And optionally, if you don’t wan’t to remember your external ip, or if your internet provider changes it to often, we will use the Dynamic DNS service from NO-IP.
Redirecting the request to the port 80 to our yun.
The steps that we have to do to redirect the requests to the arduino YUN, will depend on the brand and model of our home router. I will show you how to do it on an EchoLife HG553 of Vodafone, but in other routers the stepd will be very similar.
The first step is to access to the control panel. You need to know the ip of the router, in my case, the ip is:
If you access this url using a web browser, you will be requested to introduce an user and password. In case of this router, the user is “vodafone”, and the password is “vodafone”.
Now, on the left side, you have to go to the menu Firewall->Port forwarding.
You will see a form like the following, where you can add a forwarding rule. Select the service HTTP from the list, and in the “local ip” field introduce the IP of your arduino YUN, like in the following picture:
Save the changes, and check if your arduino yun is accessible from another network (not your home network), by accessing the following url: http://my_external_ip/
If you don’t know which your external ip is, you can obtain it here:
Using NO-IP to have a free Dinamic DNS Service.
First, sign up in NO-IP for a free account, and in the main menu, click on “add host”.
You have to fill the following form:
In the example above, we have created an dynamic dns to access our arduino yun across the internet using http://what_you_want.redirectme.net instead of http://126.96.36.199
Maintaining the free account on NO-IP alive.
The free account of no-ip will expire after 30 days. Because of that, our arduino will take care of update our ip in NO-IP once per day. We will do that using shell scripts on the Arduino YUN executed periodically.
This will help too in case our internet provider changes our external ip very often.
¿How to obtain our external ip with php?
That is not very difficult. We will use the following snippet of php code:
And to do the update in NO-Ip, we will call the following web service:
Please, double check that you can access your arduino yun with your home network, and outside your home network before proceeding with the next steps.