YUN to YUN wifi connection

Hi all. I am very new to the world of Arduino but am excited about what I have already learnt. My question to all you Arduino guru's out there is how can I connect one YUN to another YUN via their own WiFi. Example: i have a yun that i want to push a button on and turn on a light that is driven via a second yun that is not connected in anyway by cables or close enough to any existing network.

Cheers for any help! ;D 8)

Set one up as a WiFi access point - just like the way it behaves out of the box before you reconfigure it. You can use the default configuration as is, but you will probably want to change the name and enable some security. You will have to go into the Advanced Configuration pages, under the Network -- WiFi tab to do this, I don't believe you can do it from the first configuration page (the page where you set the Yun's name and can configure an open/secure REST API.) During this configuration, you will be giving the Yun an IP address, make note of it.

Then, once that's done, do the standard WiFi setup of the second a Yun, but instead of setting it up to connect to your home WiFi network, select the network you set up on the first Yun. Things will be much easier when it comes to the communications programming if you go into the advanced configuration pages and assign a static IP address to this Yun. One thing worth noting: there is a function that is run shortly after booting that checks whether the Yun is connected to the configured WiFi network, and if it isn't it resets back to the default factory access point mode. This is a safety net that if you misconfigure the WiFi, it reverts back to a state where you can connect back into it and try again. This may cause you problems unless the first Yun is always powered up and in range 100% of the time. To disable this "feature" go into the advanced configuration pages of the Yun, and under the System -- Startup tab, down at the bottom is a large edit box for the /etc/rc.local startup script: find the line that says wifi-live-or-reset and add a # character in front of it to comment out that function call. (You can also SSH into the Yun and edit /etc/rc.local directly if you know how to do that.)

Now that you have the Yuns connected to each other, you need to send a command from one to another. Perhaps the easiest way is to use the Bridge Library's mailbox feature. To get started, run the Mailbox Read Message example on the Yun that is to receive the command. Then, on the other Yun, take the HTTP Client example and change the URL from "http://arduino.cc/asciilogo.txt" to "http://yunAddress/mailbox/command" where yunAddress is the IP address of the Yun, and "command" is the command or message you want to send to the other Yun.

There are many other ways to handle the communications between the two Yuns. This particular method is not the fastest or most efficient method, but it's easy. What method you actually use will depend on how much data you want to move between them and how fast, what your programming proficiency is, and whether you are willing to do a lot of the work on the Linux side where things get much more efficient.

None of this is a set of detailed step-by-step instructions, but rather guidance on a general direction to take. I don't know your level of expertise, so I don't want to go into excruciating detail if you don't need it. If you need more help, try searching for details on the topic, and shout out here if you get stuck.

Good luck!

Cheers for that ShapeShifter.

I will have a go at that this afternoon. So excited....... :smiley: ;D ;D :grin: :grinning:

I thought it would be pretty easy but I am not that switched on with all the technology.

My issue with connection between the YUN's is that I have a distance of 150 metres and nothing to physically connect them. Is there a better way in this case than the WiFi?

Thanks again