:: Arduino Yún ::


The Arduino Yún is a microcontroller board based on the ATmega32u4 and the Atheros AR9331 processor which run a Linux distribution named Linino.

Hardware Features
  • built-in Ethernet and WiFi support
  • one USB host port
  • micro-SD card slot
  • 20 digital input/output pins
  • 7 PWM outputs
  • 12 analog inputs
  • a 16 MHz crystal oscillator
  • micro USB connection
  • ICSP header
  • 3 reset buttons

Basic documentation by the Arduino Team

These documents are a must read for all owners of an Arduino Yún.

Interestings topics discussed on the Forum

The Yún has its own section on the Arduino forums. People try new things every day, so there is a lot of useful information to be found in the topics discussed on the forum. But with every new post or question the older topics get pushed down the stack. Once they are on page 5 or so they are actually out-of-sight and people start to ask questions which have already been answered.

So it seems to be a good idea to keep a reference to some of the more important topics.

Topics

Power consumption of the board

Power consumption in mA
Configurationmintypicalmax
WiFi on, no wired connection, no sd170240300
WiFi on, wired connection, no sd 277 
WiFi on, wired connection, no sd, max. load 315 

Disabling the WiFi on the board saves ~20mA

(original forum topic | last edit : September 26, 2013)

PoE module for Yun

Yun supports a PoE module, but currently (03/2014), YuN is not available pre-soldered with a PoE module, so you need to buy a PoE module separately and solder it. There is no _nice_ way to solder the PoE module, because the metal shield over the arm cpu and wifi chip is in the way of the PoE module. It either needs to be removed or cut to fit the PoE module.

Here is a picture of a YuN with soldered PoE module and cut shield:

Arduino Ethernet-Shield/Board-Ethernet use a PoE module that outputs 12V which is then converted to 5V by the arduino on-board voltage regulator. This limits the total power output at 5V to what that voltage converter provides (~ 500 mA). There is no such power regulator on YuN, so the PoE module for Yun must directly provide 5V. The 5V equivalent to the 12V converter used on Ethernet-Shield/Ethernet-Board (Silvertel AG9120S) is the Silvertel AG9050S. It is available for example here:

This PoE converter provides a total of 9W @5V, leaving ample power for I/O connected to YuN.

Building the Linux image for the Yún

The Yún runs a Linux distribution called linino which is based on the well known OpenWrt project. The source code for the linino distribution is on github: https://github.com/arduino/linino

If you want to rebuild (cross-compile) the linino distribution image from scratch, here is a basic recipie.

For the build we need a Linux machine running a Debian based distribution. In the original post Ubuntu 12.04 was used (in a virtual machine).

Linux build setup

Install a recent version of Ubuntu (12.04 is reported to be working) and install the packages needed for cross-compiling the linino distribution.

sudo apt-get install python sed wget cvs subversion \
git-core coreutils unzip texi2html texinfo \
docbook-utils gawk python-pysqlite2 diffstat help2man \        
make gcc build-essential g++ desktop-file-utils \
chrpath flex libncurses5 libncurses5-dev  zlib1g-dev \ 
pkg-config gettext libxml-simple-perl guile-1.8 cmake \
libssl-dev xsltproc fastjar mercurial pngcrush \
imagemagick tcl binutils bzip2 perl grep diff \
libz-dev openjdk-7-jdk

Get the Linino repository and OpenWRT updates

git clone https://github.com/arduino/linino.git
cd linino/trunk
./scripts/feeds uninstall -a  
rm -rf feeds
./scripts/feeds update -a
./scripts/feeds install -a

Create a new build config

rm -f .config
git checkout .config
make oldconfig

Build the image

Don't get impatient here, this takes a few hours!

make

If you would like to see lots of status messages or if the compilation stopped because of an error use

make V=s

(original forum topic | last edit : September 26, 2013)

Using an µSD card (or any other external storage)

As soon as you plug an µSD card in to the Yún, it becames accessible at folder /mnt/sda1. If you have one µSD card and a pen drive, former will have folder /mnt/sda1 and latter /mnt/sda2.

You can find your project's www folder on your µSD under /mnt/sda1/arduino/www or /www/sd.

In its factory setup, Yún supports the following file systems: FAT32 (including vFAT), EXT3/4, HFS(+), Reiser, Fuse, and NTFS. You can extend the number of supported formats by installing additional packages for MSDOS, ISO, BtrFS, MinixFS, UDF, XFS, CiFS, and NFS. Even AutoFS support can be added. FAT64 ist not supported.

(original forum topic | last edit : September 27, 2013)

(original forum topic | last edit : December 3, 2013)

Installing PHP (5 or 4)

In order to install php5 or php4, be sure your Yún can access the internet then, via SSH or via the YunSerialTerminal, issue commands

opkg update
opkg install php5 php5-cgi

Php5-cgi is good for making web sites. If you want to use php as a command line interpreter, install php5-cli

(original forum topic | last edit : September 20, 2013)

Running multiple websites

If you're into web development, you'd like your Yún to run multiple web sites.

You need to edit uhttpd (the web server) config file, located at /etc/config/uhttpd . Many options are available at openwrt.org web site.

The following is just an example

config uhttpd main
    list listen_http	0.0.0.0:80
    option home		/www
    option cgi_prefix	/cgi-bin

config uhttpd secondary
    list listen_http	0.0.0.0:81
    option home		/mnt/sda1/arduino/www/
    option cgi_prefix	/cgi-bin

(original forum topic | last edit : September 26, 2013)

Sharing data between your python scripts and your sketch

You can user module bridgeclient.py located at /usr/lib/python2.7/bridge to share data between your python script and your Bridge powered sketch.

Take a look at the code snippets on the original forum topic to get inspiration.

(original forum topic | last edit : September 26, 2013)

Get "time" to work in PHP

You need to install the appropriate zoneinfo package. Via SSH or via the YunSerialTerminal, issue commands

opkg update
opkg install zoneinfo-core
opkg install zoneinfo-europe

Type opkg list | grep zoneinfo and look for your timezone

(original forum topic | last edit : September 29, 2013)

Get "json" to work in PHP

Via SSH, issue commands

opkg update
opkg install php5-mod-json

then edit file /etc/php.ini and uncomment the line extension=json.so

(original forum topic | last edit : September 29, 2013)

Unable to connect: is the sketch using the bridge?

Many users find that some examples just don't work: they upload them via wifi then open the serial monitor and read

Unable to connect: retrying (1)...
Unable to connect: retrying (2)...
Unable to connect: retrying (3)...
Unable to connect: retrying (4)...
Unable to connect: is the sketch using the bridge?

Most of the examples sketches EXPECT to be uploaded via USB cable, not via wifi.

Solution: close the serial monitor, select the proper port (COM or /dev/tty...) from the Port menu and reopen the serial monitor.

Sending HTML/XML/other from YunServer/YunClient

By default, when using "/arduino/" prefixed APIs, YunClient generated responses are treated as plain text. So, for example, if you print HTML code, you'll see the HTML code instead of the HTML page, nicely rendered by the browser.

To make things happen the right way, you need to override the default behaviour, setting the appropriate HTTP Headers, like so

client.println("Status: 200");
client.println("Content-type: text/html");
// any other header
client.println(); //mandatory blank line
client.println("<html><body>Hello world!</body></html>") //the response body

(original forum topic | last edit : October 1, 2013)

Guide to Setup Streaming Web Cam on the Yun

(original forum topic | last edit : September 18, 2013)

How to Run Sqlite3 and PHP on Arduino Yun

Install php5-mod-sqlite3 - 5.4.17-1, And of cource the other PHP modules you need

Example php5

     db=new SQLite3("/mnt/sda1/arduino/www/test/ec.db");
     $results = $db->query('SELECT * FROM Navn');
     while ($row = $results->fetchArray()) {
     var_dump($row);
     print $row[1];
     }

How to Run Sqlite3 and Python on Arduino Yun

Install python-sqlite3 - 2.7.3-2, And of cource the other Python modules you need

Example python script

#!/usr/bin/python

import sqlite3 as lite
import sys

con = lite.connect('/mnt/sda1/arduino/www/test/ec.db')

with con:
    cur = con.cursor()
    cur.execute("SELECT * FROM Navn")
    rows = cur.fetchall()
    for row in rows:
        print row

Python module installing

In order to keep used disk space as low as possible, few softwares on the Yún support SSL out-of-the-box. Python SSL support is optional and must be manually installed before attempting to install additional modules via easy_install.

For example, in order to install python module "pygeocode", you need to issue the following commands via YunSerialTerminal or SSH

opkg update #updates the available packages list
opkg install distribute #it contains the easy_install command line tool
opkg install python-openssl #adds ssl support to python
easy_install pip #installs pip
pip install pygeocode #installs pygeocode

(original forum topic | last edit : October 13, 2013)

Fixing the Spacebrew installation on the Yún

If you tried to run the Spacebrew examples, you may have noticed that the connection with the server never happens. This is because the Spacebrew scripts that ship with the Yún need to be patched.
Here is an explanation: http://goo.gl/zh1DtL
Here is how to get the latest version of yunSpacebrew on your Arduino:

  1. Download the archive of that repo:
    https://github.com/julioterra/yunSpacebrew
  2. Go through the installation instructions for linino python and shell scripts:
    https://github.com/julioterra/yunSpacebrew#installing-linino-python-and-shell-scripts

(Original forum topic | last edit : November 24, 2013)

Yun Bootup process

Several people have asked about what happens when you apply power to the Yun or use the Yun Reset button. This can be confusing mainly because the Leonardo part comes up very quickly and the Linino part takes around 60 seconds.

You can watch what happens by loading the Yun serial terminal sketch via USB, openning the serial monitor and pressing the Yun Reset button near the LEDs. You can interact with the boot process if bad things happen so you can fix them, without this you could end up "bricked" with no way to "unbrick".

The first opportunity for interaction is to stop uboot when you see "Hit any key to stop autoboot: " so you can flash/boot if the image is bad. It is best to let this go by if your Yun will get to the failsafe prompt, official information on how to restore the image with uboot is here http://arduino.cc/en/Tutorial/YunUBootReflash but as the webpage notes use this a a last resort. Next is the "Press the [f] key and hit [enter] to enter failsafe mode" prompt, failsafe mode allows you to fix things that are messed up in the linux system configuration, if you disabled the console in inittab you can run mount_root in failsafe and then re-enable it here. Once you get thing fixed you can execute reboot -f or just power cycle the Yun to boot up. Next is the console started in inittab which allows you access if you lose network connectivity. This should be available unless you disabled it in inittab and most things can be fixed here.

While you could run for years without needing these things they are nice to have, kinda like airbags in a car, if you need them you are VERY glad you had them.

(Original forum topic | last edit : November 24, 2013)

My Yún doesn't boot anymore! How can I restore it?

If you cannot even reset the Yún with its reset button, you may have filled your flash and linux is not even able to start. In this case, you need to

  • Upload the YunSerialTerminal example via usb
  • Reset the AR9331 (white button near the leds)
  • Wait until you read "Press the [f] key and hit [enter] to enter failsafe mode": do that, press f and hit enter
  • Type cd /usr/bin
  • Type ./reset-to-factory-anyway (this will reset the Yún to factory settings)

Now the Yún should restart and you should be able to configure it like you you first got it out of the box.

How can I connect to a shared linux drive? (cifs)

If you have a computer that shares a drive in the cifs (Common Internet File System) format you can access it from your yun.

to do so you need to install some packages:

opkg update 
opkg install  cifsmount
opkg install kmod-fs-cifs

If you have your share encrypted there may be a need for more packages.

Once these packages installed you can mount a drive Make sure you mount on an existing folder. For instance like:

mkdir -p /mnt/local
mount.cifs //192.168.0.20/Shares /mnt/local -o guest,sec=ntlm

If you want to mount password protected drive at boot time you must supply the name and password to avoid a request for it.

mkdir -p /mnt/local
mount.cifs 192.168.1.205:/linksys /mnt/nas -o user=XXXX,pass=YYYY,sec=ntlm

note that you can replace the ip adress with a server name when your yun is able to ping to the servername.

(Original forum topic | last edit : October 26, 2013)

I can't connect to my Yún via SSH

Note: The proposed solution is using a Mac/Unix command line

You get scary “POSSIBLE DNS SPOOFING” or "REMOTE HOST IDENTIFICATION HAS CHANGED" warnings when trying to connect via ssh. This can happen when you fiddle a lot with renaming/resetting your Arduino Yún.

In that case, sudo ssh root@arduino won't work, and your correct password won't be accepted: (You'll keep getting the message: Sorry, try again).

The error tells you to Add correct host key in ~/.ssh/known_hosts to get rid of this message. Actually, the solution is to remove the incorrect keys then try to reconnect.

  1. Back up: $ cp ~/.ssh/known_hosts ~/.ssh/known_hosts.bak
  2. Open your known_hosts file in vi (or use your prefered text editor): vi ~/.ssh/known_hosts
  3. Delete the lines that start with "arduino" and any name you once gave to your Yún: In vi, type dd to delete the current line.
  4. Save and quit: :wq
  5. Connect again: ssh root@arduino or ssh root@[name or IP of your Arduino]
  6. You should be told that the authenticity of the host cannot be verified and asked (twice) "Are you sure you want to continue connecting": type yes

Share