The Arduino Yún is an Arduino board unlike any other. While programming it is very similar to the Arduino Leonardo and uses the same processor, the Atmel ATmega32U4, it also has an additional processor, an Atheros AR9331, running Linux and the OpenWrt wireless stack. Programming the 32U4 via USB is identical to the Arduino Leonardo. Once you've configured the Yún to connect to your WiFi network, you can program the 32U4 via WiFi as well.
The Arduino Yún is programmed using the Arduino Software (IDE), our Integrated Development Environment common to all our boards. You should have already it installed on your PC, as explained in the home page of our Getting Started.
The first time you plug a Yún into a Mac, the "Keyboard Setup Assistant" will launch. There's nothing to configure with the Yún; you can close this dialogue by clicking the red button in the top left of the window.
Select the serial device of the board from the Tools | Serial Port menu. This is likely to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find out, you can disconnect your board and re-open the menu; the entry that disappears should be the Arduino or Genuino board. Reconnect the board and select that serial port. When your board is properly configured on WiFi, you will find it in the Port list, as in our screenshot.
A few seconds after the upload finishes, you should see the on-board LED start to blink. If it does, congratulations! You've gotten your Arduino Yún up-and-running. If you have problems, please see the troubleshooting suggestions.
Now that you have set up and programmed your Yún board, you may find inspiration in our Project Hub tutorial platform, or you can dig in deeper with the Bridge library and examples. You can also check out the Yún hardware page for additional technical information.
In addition to the 32U4 chip, the Yún has an additional processor, an Atheros AR9331, which runs a distribution of Linux for embedded systems named OpenWrt-Yun, based on OpenWrt. A full install of Python 2.7 is included as well.
The Yún has a number of different physical characteristics and connectors than the Leonardo. There is an on-board SD slot, Ethernet jack, and a USB-A Host connector. There is no power barrel connector on the Yún; it can be powered from the micro-USB connector.
There is no built in 5V regulator. If you power your Yún with more than 5V, you will likely damage it. If you are not powering the Yún from the micro-USB connection, you can apply power to the VIN and 5V pins on the board. If using the VIN pin, you cannot provide more than 5V, it will damage your board. It is recommended to power the Yún from the USB connection whenever possible.
The SD, Ethernet, and USB-A connectors are not physically connected to the 32U4 processor, they are connected to the AR9331.
The Yún's 32U4 functions in the same way as the Leonardo, except you cannot use Serial1. It is reserved for communication with the AR9331 processor.
The Yún also has a WiFi module built on board, allowing it to connect to a wireless router, or act as an access point.
The 32u4, WiFi, and AR9331 processors all have their own reset buttons.
There are several status LEDs on the Yún, indicating power, WLAN connection, WAN connection and USB. Additionally pin 13 is connected to one of the status lights.
The Yún runs a distribution of Linux called OpenWrt-Yun, based on OpenWrt. While it's possible to configure the system from the command line, there is a web page that allows you to configure many of the different options available. The interface (called LuCi) gives you access to most any setting you would need for maintaining the WiFi interface.
Accessing the web interface is described below.
To install additional software on OpenWrt-Yun, you need to use the the Linux package manager opkg. For more information on the manager and some common commands, see the Yún package manager page.
When interfacing with the OpenWrt-Yun system, you have to use a command line, either accessing it through the Arduino's Bridge library, or via SSH. If you are unfamiliar with the command line, you may want to read about some basics about it and some of the programs that are frequently used.
Due to continuous improvements and suggestions coming from both the OpenWrt community and the Arduino community, version of OpenWrt-Yun installed on your Yún may be out of date. Please check the upgrade tutorial and be sure you're running the latest version available.
An installation of Python 2.7 is included with OpenWrt-Yun, with which you can write applications or scripts. For more on Python, visit the Python 2.7 documentation pages.
If you're getting started with Python for the first time, there are a number of excellent resources on-line. "Learn Python the Hard Way" will cover everything you need to know to get up and running with your own scripts.
You're discouraged from using the Yún's built-in non-volatile memory, because it has a limited number of writes.
You can use external memory like a microSD card or thumb drive for saving data, or your own scripts, web pages, etc. For the Yún to access and store information on these drives through the 32U4, they need to have a directory named arduino in the root of the volume.
OpenWrt-Yun uses REST for clients and servers. REST is an acronym for "Representational State Transfer". It is a software architecture that exposes various parts of the Arduino hardware through URLs.
By default, the REST API access is password protected. It is possible to change this to access the services without a password. To change this setting, enter the Yún configuration panel. At the bottom of the page, you will see toggles for changing the access.
A nice introduction to the concepts behind REST can be found here.
The "/arduino" directory doesn't have anything pre-configured. Anything added to the URL after the end point is passed from the webserver to the sketch on the 32U4. You can define your APIs inside the sketch. See the Bridge example to see how this is done to access the pins on the board.
/get : obtains the entire storage list in JSON.
To restart the AR9331, which reboots OpenWrt-Yun, press the "YÚN RST" reset button that is close to the analog inputs pins and the LEDs of the board.
To restart the the 32U4 and restart the currently installed Arduino sketch, tap the button next to the Ethernet port two times.
The reset button for WiFi is located next to the USB-A connector. It is labeled "WLAN RST". When you press the button, the WLAN LED will flash.
If you move to a different network and can no longer wirelessly access the Yún through its web interface, you can reset the Yún's network configuration by pressing the WiFi reset button (WLAN RST) for longer longer than 5 seconds, but less than 30, the AR9331 processor will reboot. The WiFi configuration will be reset and the Yún will start its own wiFi network Arduino Yún-XXXXXXXXXXXX. Any other modification/configuration will be retained.
To reset the OpenWrt-Yun distribution to its default state, press the WiFi reset button (WLAN RST) for at least 30 seconds. The board reverts to the original settings: like just taken out of the box or to the latest update of the OpenWRT image you have reflashed before. Among other things, this removes all installed files and network settings.
Now you have to execute the passwd command to change the password. Type passwd into the serial monitor input and press enter. You will be asked to type the new password, and re-type it to confirm. If you want, you can ignore the weak password error. If both passwords you typed match, the system password will be changed and you will be able to access to the webpanel with the new password.
Since the Yún does not have a dedicated chip to handle serial communication, it means that the serial port is virtual -- it's a software routine, both on your operating system, and on the board itself. Just as your computer creates an instance of the serial port driver when you plug in any Arduino, the 32u4 creates a serial instance whenever it runs its bootloader. The board is an instance of USB's Connected Device Class (CDC) driver.
This means that every time you reset the 32U4 processor, the USB serial connection will be broken and re-established. The board will disappear from the list of serial ports, and the list will re-enumerate. Any program that has an open serial connection to the Yún will lose its connection. This is in contrast to the Arduino Uno, with which you can reset the main processor (the ATmega328P) without closing the USB connection (which is maintained by the secondary ATmega8U2 or ATmega16U2 processor). This difference has implications for driver installation, uploading, and communication.
The Yún won't restart your sketch when you open a serial port on the computer. That means you won't see serial data that's already been sent to the computer by the board, including, for example, most data sent in setup().
This also applies to the Console, described below.
The Yún has the ability to act as an Access Point, but it can also connect to an existing network. These instructions walk you through connecting your Yún to a wireless network. The Yún can connect to unencrypted networks, as well as networks that support WEP, WPA, and WPA2 encryption.
When you first power on the Yún, it will create a WiFi network called ArduinoYun-XXXXXXXXXXXX. Connect your computer to this network.
Once you've obtained an IP address, open a web browser, and enter http://arduino.local or 192.168.240.1 in the address bar. After a few moments, a web page will appear asking for a password. Enter "arduino" and click the Log In button.
In the Yún NAME field, give your Arduino a unique name. You'll use this to refer to it in the future.
If you wish, you can set the timezone and country. It is recommended to set these options as it may help connecting to local WiFi networks. Setting the local timezone also selects the country's regulatory domain.
When your Yún is on the same network as your computer, you can connect to it wirelessly to program it.
After configuring your Yún, connect to the network you specified in the configuration settings. Open the Arduino IDE.
Under the Tools > Port menu, you should see an entry that lists your Yún's name and its IP address. Under the Board menu, select Arduino Yún.
Open the Blink example (File > Examples > 01Basics > Blink) and upload the sketch to the board. You will be prompted for the administrator password. Use the one you entered in the configuration screen.
Once the program is uploaded, the 32U4 processor will restart. You should see the LED connected to pin 13 blinking.
When you connect the Yun to a wired network with an ethernet cable, it will try to connect automatically via DHCP. The board will show up on the ports menu just as it would over WiFi.
If you want to connect the Yun directly to your computer, either configure the computer's interfaces to have a static IP address, or act as a DHCP server.
The Bridge library enables communication between Arduino and OpenWrt-Yun. There are several different utility classes that facilitate different kinds of communication between the two, described below, and more in depth on the Bridge library reference pages.
The WiFi and Ethernet interfaces, USB host, and SD card are all connected to the AR9331. The Bridge library allows you to work with these devices, as well as run scripts and communicate with web services.
The Console, based on Bridge, enables you to send information from the Yún to a computer just as you would with the serial monitor, but wirelessly. It creates a secure connection between the Yún and your computer via SSH.
NB: If you are using Windows, you must install a terminal emulator. PuTTY is a reasonable choice, but you will have to enter the two commands above separately.
Type 'H' to turn the LED on pin 13 on and type 'L' to turn it off.
The Process commands allow you to run Linux processes on OpenWrt-Yun through the Arduino.
In the following example, The OpenWrt-Yun will connect to a server with curl, and download some ASCII text. It prints the text a serial connection.
p.addParameter("http://arduino.cc/asciilogo.txt"); // Add the URL parameter to "curl"
Bridge allows you to pass information between the two processors using a key/value pairing.
This example shows how to use the Bridge library to access the digital and analog pins on the board through REST calls. It demonstrates how you can create your own API when using REST style calls through the browser.
When running this example, make sure your computer is on the same network as the Yun.
When you have have programmed the board, you can request the value on a pin, write a value to a pin, and configure a pin as an input or output.
Instantiate a server enabling the the Yun to listen for connected clients.
In the second part of setup(), tell the instance of YunServer to listen for incoming connections only coming from localhost. Connections made to OpenWrt-Yun will be passed to the 32U4 processor for parsing and controlling the pins. This happens on port 5555. Start the server with server.begin().
You can find more details on this example on the Bridge Example page.
The Yún comes with several pieces of software pre-installed on OpenWrt-Yun, including "curl" and "python". You may want to install other software on the Yún. On Linux systems, additional software can be installed using a tool called the "package management system". For more information, refer to the package manager tutorial.