Skip to main content
edited body
Source Link
CharlieHanson
  • 1.4k
  • 1
  • 11
  • 26

In breifbrief:

In breif:

In brief:

added 132 characters in body
Source Link
CharlieHanson
  • 1.4k
  • 1
  • 11
  • 26
  1. In the Yun sketch change server.ListenOnLocalhost(); to server.noListenOnLocalhost();In the Yun sketch change server.ListenOnLocalhost(); to server.noListenOnLocalhost(); - the subtle difference is the 'no', and is essential for external control. - the subtle difference is the 'no', and is essential for external control.Sorry, that's incorrect without a little more explanation than is required at the moment to answer your original question.

  2. In the .html file, you need to change each instance of:

    server = "/arduino/"; to

    server = "YOUR.IP.ADD.RES:PORT/arduino/"; If you have the REST password set to ON then you have to incorporate the username/password in there too:

    server = "username:[email protected]:PORT/arduino/"; There are three occurences in the original file, so be sure to catch them all.

  3. When making changes to the .html file, make sure you re-upload it to the external host, not the Yun - that mistake took me hours to figure out.

  1. In the Yun sketch change server.ListenOnLocalhost(); to server.noListenOnLocalhost(); - the subtle difference is the 'no', and is essential for external control.

  2. In the .html file, you need to change each instance of:

    server = "/arduino/"; to

    server = "YOUR.IP.ADD.RES:PORT/arduino/"; If you have the REST password set to ON then you have to incorporate the username/password in there too:

    server = "username:[email protected]:PORT/arduino/"; There are three occurences in the original file, so be sure to catch them all.

  3. When making changes to the .html file, make sure you re-upload it to the external host, not the Yun - that mistake took me hours to figure out.

  1. In the Yun sketch change server.ListenOnLocalhost(); to server.noListenOnLocalhost(); - the subtle difference is the 'no', and is essential for external control. Sorry, that's incorrect without a little more explanation than is required at the moment to answer your original question.

  2. In the .html file, you need to change each instance of:

    server = "/arduino/"; to

    server = "YOUR.IP.ADD.RES:PORT/arduino/"; If you have the REST password set to ON then you have to incorporate the username/password in there too:

    server = "username:[email protected]:PORT/arduino/"; There are three occurences in the original file, so be sure to catch them all.

  3. When making changes to the .html file, make sure you re-upload it to the external host, not the Yun - that mistake took me hours to figure out.

Source Link
CharlieHanson
  • 1.4k
  • 1
  • 11
  • 26

I have accomplished this, first by reading this article on controlling a Yun through a web-browser on the same network. From there it was a matter of allowing my Yun to be accessed externally (setting up port-forwarding on my router) and changing a few lines of code to reflect the new location reference.

All the necessary files and code are included under the heading "Project Files" in the above link and no modification is needed to get it working within the same network. That said, I had to convert the two .jpg files to .png (and change the filenames in index.html) - I don't know why they wouldn't show up in my browser.

In breif:

The Yun hosts a webpage (index.html) which contains some indicators and control inputs. These objects are linked to the 32u4 using Bridge and the REST API - nothing special. The bulk of the html code is for visual purposes, and the actual REST calls are nice and simple.

What is good is that the webpage can be accessed from anywhere with the right jiggery-pokery, and with a little more determination can be hosted from anywhere.

External Access

Once you have that working, you need to do the following to allow access externally. I tested this using my smartphone - disconnected from my home WiFi of course - to ensure the link was over the Internet, not intranet.

  1. Set up port forwarding and a static IP for the Yun. This is the fundamental step if you simply want to control your Yun over the Internet. However, I can't actually tell you how to do this because I don't know what equipment you have! Information is all over Google for setting up both DHCP static IP and port forwarding.

  2. Get a static IP from your ISP for your home/work, or set up a Dynamic DNS service (these people offer it free, but I've never actually needed to use an external service). Most commercial ISPs tend to dish out static IPs, but that's no guarantee that yours will.

  3. Access your Yun with a browser via: http://YOUR.IP.ADD.RES:PORT/arduino/<SketchName>.

External Hosting

If you want to host the webpage on something other than the Yun, you can! You will of course need a server to host this, either your work's central server or an external hosting service. You'll need to change some more lines in the code:

  1. In the Yun sketch change server.ListenOnLocalhost(); to server.noListenOnLocalhost(); - the subtle difference is the 'no', and is essential for external control.

  2. In the .html file, you need to change each instance of:

    server = "/arduino/"; to

    server = "YOUR.IP.ADD.RES:PORT/arduino/"; If you have the REST password set to ON then you have to incorporate the username/password in there too:

    server = "username:[email protected]:PORT/arduino/"; There are three occurences in the original file, so be sure to catch them all.

  3. When making changes to the .html file, make sure you re-upload it to the external host, not the Yun - that mistake took me hours to figure out.

A little more...

While searching for the URL of the article in the opening paragraph I found this atricle on a similar theme. It looks to have plenty of information although I haven't read it yet fully yet; I've been busy writing an answer on Stack Exchange. External Access should be no different, and if you want the 'External Hosting' version you just need to find any line that references the 'server' as "/arduino/..." and change it to "YOUR.IP.ADD.RES:PORT/arduino...".