Hands on the Arduino Yún

Arduino Yún

The original Arduino Yún and its successor the Arduino Yún Rev. 2 are a mixture of an Arduino board with a WiFi connected Linux board. And, of course those two parts are bridged, so you can easily build applications that interact with their environment via the digital or analog pints, and run a web server or perform some computations on the Linux part (See Video 1 below).

In this tutorial, we will get started with the Yún. I’ll also provide you with some tips and tricks that hopefully will help you in your experiments.

arduino Yún BoardOutline

Video 1: Overview of the Arduino Yún

Powering the Arduino Yún

First things first, you need to plug the Yún to a power source prior to using it. There are 3 ways to deliver power to the Yún. The first option is simply through USB. This is typically done by connecting the board to a PC our a USB hub via Micro-B USB cable. The second option is through the ethernet plug since the Yún does support Power over Ethernet (PoE). The third solution is to use an external electric power source through the Vin and Ground pins. But then, you need to be careful because the there is no built in 5V regulator. If you power your Yún with more than 5V, you will likely damage it. A simple way to avoid this is to use a 3LR12 lantern battery which delivers 4.5V.

WiFi Setup

Once the Yún is connected to a power source, few seconds are required to Linino to boot. Then, you’ll see a Wifi network with a name starting with “Arduino Yun”. The full name looks like Arduino Yun-XXXXXXXXXXXX, where the Xs are alphanumerical characters. The Yún acts by default as an access point. So, you can connect your computer to the ArduinoYun Wifi and start interacting with the Yún.

You can replace this configuration and make the Yún connect to another Wifi network. This change is very easy likewise most of the setup. All you have to do is to access the configuration web interface using a web browser that opens the http://arduino.local address.

Checking the Connection

Once connected, you can open a terminal and ping the board to check that the Linino is ready by evaluating:

ping arduino.local

The arduino.local refers to your board in the local network. So, if you replace its name (through the configuration web interface) to say myYun, you should be using myYun.local instead of arduino.local. Anyway, if the everything is ok, you should get an answer similar to the following:

PING arduino.local (192.168.240.1): 56 data bytes
64 bytes from 192.168.240.1: icmp_seq=0 ttl=64 time=1.225 ms
64 bytes from 192.168.240.1: icmp_seq=1 ttl=64 time=2.502 ms
64 bytes from 192.168.240.1: icmp_seq=2 ttl=64 time=2.551 ms

Logging into Linino

The Linux carried by the Yún is a distribution based on OpenWRT named Linino (also referred to as OpenWrt-Yún). Logging into Linino can be done as with any Linux through ssh from a terminal of a computer that is on the same network as the Yún. The default user is root. So, to login in you need to type the following command line:
ssh root@arduino.local
The first time you try to connect to your Yun from a computer, the terminal will reply with a message like this :
The authenticity of host 'arduino.local (192.168.240.1)' can't be established.
RSA key fingerprint is c6:4a:45:ab:51:56:17:08:3a:04:54:14:ad:82:f8:fa.
Are you sure you want to continue connecting (yes/no)?
Type yes at this prompt to continue the process. You’ll get a response that says:
Warning: Permanently added 'arduino.local,192.168.240.1' (RSA) to the list of known hosts.
Next, you will get prompted to provide the password. By, default it is arduino. Of course you can change it through the web interface too. Et voilà, you’re in! You will quickly notice that Linino is a stripped down Linux. For example, there is no man by default. So, expect some adjustments depending on your project. Still, you can expand the default setup by installing extra packages using the package manager opkg.

Resetting the Yún

The Yún offers different kinds of reset:

  • To reboot the microcontroller (Leonardo part) only, press the 32U4 RST button (see Figure 1 below).
  • To reboot the linux system only, press the YÚN RST button near the analog input pins.
  • If you want to reset the Wifi and make the Yún revert to its original Wifi setup (i.e. Wifi host spot with SSID Arduino Yun-XXXXXXXXXXXX), press the button labelled WLAN for more than 5 seconds. The WLAN button is located near the host USB connector (the big one). Note that while the WLAN button is pressed the WLAN led will blink in blue.
  • If you did mess up with your board configuration, or you simply need a fresh setup for a new project or experiment you can do a full reset and make the Linino go back to its default state. Press the WLAN button but this time for more than 30 seconds.
Arduino Yún Reset Buttons
Figure 1. Arduino Yún Reset Buttons

Controlling the Arduino Yún Over WiFi

The Yún can run a web server that allows interacting with your Arduino sketch via a web browser on a remote computer.  It relies on the REST protocol. REST is an acronym for “Representational State Transfer”. Basically, it allows to a talk to an Arduino sketch through URLs as when you browse the web.

Example Setup

An example showing how to control the Yún over Wifi is available on my github.  The sketch controls the Arduino Yún on board LED based on commands sent by a web browser.

To run this example you need to do the following:

Control the LED using a Web Browser

The sketch allows to control the onboard LED on pin 13.  You can either turn it ON, turn it OFF, make it blink, or fade. You’ll find below examples of URLs you can write on your web browser, and remotely command the LED. I assume that the board’s name is set to yun.

  • http://yun.local/arduino/on Turn ON the LED
  • http://yun.local/arduino/off Turn OFF the LED
  • http://yun.local/arduino/blink/2/s Toggle the LED every 2 seconds
  • http://yun.local/arduino/fade/50/300/ms Fade in and out the LED changing the intensity by 50 every 300 milliseconds.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.