Yun Shield

From Wiki for Dragino Project
Jump to: navigation, search

Contents

INTRODUCTION

Dragino Yun Shield Family

What is the Yun Shield

The Yun Shield is one of the most powerful shields for Arduino Boards. The Yun Shield is designed to solve the Internet connectivity and storage issue for Arduino Board.

The Yun Shield runs the Open Source OpenWrt system (Same system as runs in Arduino Yun) and it is fully compatible with the Arduino IDE v1.5.4 or later. The Yun Shield is the ideal choice for Arduino Projects which require various internet connections and more storage.

Yun Shield w/ Leonardo

Basically, a Yun Shield + Leonardo equal the official Arduino Yun, but the Yun Shield is more flexible because it can work with other Arduino board such as Uno, Duemilanove, Mega etc. The Yun Shield uses external an wifi antenna which provides stability and the possibility for various configurations and environments.




Hardware version info

Difference between v1.x and v2.x

v1.x and v2.x are both provided , they difference between them are:

  • v1.x can be powered by DC or USB port from Arduino, while v2.x can only be powered by DC port.
  • v2.x support Micro SD card
  • v2.x support two USB host ports, while v1.x only support 1 USB host Port.



For v1.x series

  • Yun Shield v1.0: The first hardware release for the Yun Shield.
  • Yun Shield v1.1: Minor change from v1.0 according to feedback from customers.
  • Yun Shield v1.1.6:
    • Add Passive PoE port,Yun Shield can be powered by PoE Injector now
    • Change the design to auto works with 3.3v or 5v Arduino. no need to manually select jumper.
    • Level Shift is now can output more current. this increase the compatibility with different Arduino boards.
Change Log from Yun Shield v1.0 to v1.1
Change Log from Yun Shield v1.1 to v1.1.6



For v2.x series

  • Yun Shield v2.3:
    • Add an extra USB port,
    • Add Micro SD card slot.
    • v2.3 needs more power than the v1.1 in the USB part, so modified the power supply section to let it be powered by a DC adapter only.
  • Yun Shield v2.4:
    • Add Passive PoE port, Yun Shield can be powered by PoE Injector now.
    • Change the design to auto works with 3.3v or 5v Arduino. no need to manually select jumper.
    • Level Shift is now can output more current. this increase the compatibility with different Arduino boards.
Yun Shield v2.3 block disgram
Yun Shield v2.4 difference



Specifications

  • Processor: 400MHz, 24K MIPS
  • Flash: 16MBytes
  • RAM: 64MBytes
  • Power Input: 4.75v ~ 23v via Arduino VIN pin
  • 1 x 10M/100M RJ45 connector
  • 150M WiFi 802.11 b/g/n
  • External Antenna via I-Pex connector
  • 1 x USB 2.0 host connector, used for USB storage or 3G connection
  • 1 x Reset button
  • Compatible with 3.3v or 5v I/O Arduino.



Features

  • Open source Linux (OpenWrt) onboard
  • Low power consumption
  • Compatible with Arduino IDE 1.5.4 or later, user can program, debug or upload sketches to the Arduino board via the Arduino IDE.
  • Managed by Web GUI, SSH via LAN or WiFi
  • Software upgradable via network
  • Built-in web server
  • Supports internet connection via LAN port, WiFi or 3G dongle.
  • Supports USB flash to provide storage for Arduino projects.
  • Failsafe design provides robust system.
  • Compatible with Arduino Leonardo, Uno , Duemilanove, Diecimila, Mega



LEDs

There are four LEDs on the Yun Shield. The functions of these LEDs are:

  • PWR: Power Indicate LED. Turns on once there is power.
  • LAN: Indicates there is a LAN connection when it is on or blinking.
  • WLAN: Indicate WiFi status.
  • SYS: LED for USB storage. It is on if the USB flash is linked to the Arduino Yun default SD directory /mnt/sd and /www/sd



System Structure

Yun Shield Diagram
Yun Shield Diagram


Interface:

The RJ45, WiFi, USB Host and Failsafe are connected to the Dragino HE module directly. And the Dragino HE module uses SPI and the UART to communicate with the Arduino Board. The Yun Shield is compatible with 3.3v and 5v Arduino boards. The on board jumper SV1 is used to set the SPI and UART to 3.3v or 5v level.

The SPI interface is used to upload the sketches from the Arduino IDE. The SPI interface only connects to Dragino HE during uploading so the Arduino SPI can still be used to connect to other SPI slave devices.

The UART interface is used for the Bridge class in Arduino: there are lots of examples explaining how to use the bridge class in the Arduino IDE. It is the core of the Yun solution. We must make sure the serial Interface of the Arduino is not used by other hardware.

Power Requirement

Power Jumper on Yun Shield v1.1

via Arduino DC port

The Dragino HE is the core module of the Yun Shield. The HE module requires around 200mA current when at full load, so it is powered by the Arduino VIN pins to avoid overheating in the Arduino onboard 5v LDO. So when the Yun shield is used, the Arduino board should be powered by DC port instead of USB port. The DC input can be 9v ~ 15v.

The USB Host on the Yun Shield gets power from the Arduino +5v pin, since the +5v from Arduino comes from the +5V LDO, to avoid overheating on the Arduino Board, when the USB host is in use, it is recommended to use +9v DC.

via Arduino USB port (Caution)

The User can power the Yun Shield if the overall current (arduino + Yun Shield + other shields) is under the limitation of the Arduino 5V LDO. In the Yun Shield v1.1, there is a jumper (on the bottom) to define whether to power the Yun Shield from VIN or 5V USB. So the User can put the jumper to 5V position and power the Yun Shield via the Arduino USB.

If the overall current exceeds the LDO limitation, strange issue like: disconnect, reboot may happen in the Yun Shield.

Power Yun Shield via Arduino USB port for Yun Shield v1.0



via Ethernet Port Passive PoE

Yun Shield version v1.1.6 and v2.4 support Passive POE. User can power the Yun Shield and Arduino via a 8 core RJ45 cable and PoE Injector. The Yun Shield use the pinout of 802.3af mode B - with DC plus on pins 4 and 5 and DC minus on 7 and 8, . Data is then on 1-2 and 3-6 Passive PoE

The PWR from the RJ45 port is connected to the VIN pin of Yun Shield. so it can also power the Arduino. the Input of POE power is 9v ~ 15v.

RJ45 port connection of Yun Shield v1.1.6




CONFIGURE YUN SHIELD

Find the ip addresses

The Yun Shield has a WiFi interface and a LAN port. Each of them has an IP address and can be used for internet connection and device management.

Factory IP of WiFi port

Yun Shield acts as an AP at the first boot

At the first boot of the Yun Shield, it will auto generate an unsecure WiFi network called Dragino2-xxxxxx

The User can use their laptop to connect to this WiFi network. The laptop will get an IP 192.168.240.xxx and the Yun Shield has the default IP 192.168.240.1

Fall Back IP

PC setting to use FallBack IP

A fall back IP 172.31.255.254/255.255.255.252 is assigned to the Yun Shield's LAN port so the user can always access the Yun Shield with this ip if their laptop has the IP 172.31.255.253/255.255.255.252.

Detect IP from Arduino IDE

If the Yun Shield’s Ethernet port is connected to the uplink router or the WiFi interface is associated to the WiFi router, a PC in the same network can use the Arduino IDE to detect the Yun Shield’s IP address as described in Detected Yun Shield.

Configuration Method

The Yun Shield runs an Open Source Linux system. If the user has a PC on the same network as the Yun Shield, the user can access its system via either a Web Interface or Secure Shell (SSH).

Access via web interface

The recommended browsers to configure Yun Shield are Firefox and Chrome. Simply type the IP address into your browser and you will see the log in page of Yun Shield.

Yun Shield Log In Page

Default User name and Password for the Yun Shield is root/dragino.

Access via SSH

Via SSH, the user can access the Linux system directly and customize the system to support more features and applications.

Access Yun Shield via SSH

SSH Access:

IP address: IP Address of the Yun Shield

Port: 22

User Name: root

Password: dragino (default)

Web Configure Pages

General Set Up for Internet Access

After log in, the GUI will show the WIFI / ETH interface status. Click the Configure button and now the user can configure the device password and network parameters.

Configure WiFi for internet Access



Arduino related set up

Select the correct boardtype

Auto Detect AVR: Yun Shield will auto detect the Arduino AVR part and use related info to update.

Upload Profile: Auto detect.

Upload Bootloader: If checked, the Yun Shield will add the Arduino bootloader when upgrading sketch. User will be not be able to upload a sketch to Arduino if there is no bootloader in it.



Upgrade Linux Firmware

The Yun Shield firmware can be upgraded via the GUI for bug fixes / system improvement or new features. The firmware version info can be checked from this link: Yun Firmware Change log

Go to the GUI → Upgrade page and select the correct firmware to upgrade. The firmware used for web upgrade should be a sysupgrade type firmware: the user can choose if keep settings or not after an upgrade.

Upload Firmware
Upload Firmware

Normally it will take about 2 minutes to flash the new firmware. Then all the LEDS will blink together which indicates that the system is rebooting with the new firmware.

Video Instruction:



USE WITH ARDUINO BOARDS

The Yun Shield uses SPI for uploading sketches and uses the UART port for the Bridge class to talk to the AVR. While connecting the Yun Shield to Arduino Board, below points should be checked:

  • Whether the Arduino Board is power by DC jack
  • If the board type setting is correct in Yun Shield.()
  • If the board type setting is correct in Arduino IDE
  • Whether the Arduino SPI and UART is not influenced by other hardware.
  • Make sure the UART mode is in Arduino Bridge.



Connect to Arduino Boards

General How To

To use the Arduino IDE to upgrade the Arduino / AVR via local area network: the User should Add Correct Board Type in Arduino IDE.

The User may also have to do hardware modification for different boards as showed below.

Add Board Type for Yun Shield



Connect to a Leonardo

Simply plug the Yun Shield on top of the Leonardo, and power the Leonardo via the DC jack. In the Arduino IDE, the board type should select Arduino Yun.

Connect to Arduino Uno

In a UNO the uart connection between the mega328P and mega16u2 will influence the bridge feature of the Yun Shield. Therefore we have to disconnect it by setting the mega16u2 into reset mode, as below:

Use with Arduino UNO

Note: No need to put the jumper anymore in Yun Shield v1.1.6 and Yun Shield v2.4

Note: USB upgrade/debug won’t work after this change: the User will have to upgrade sketches and debug via the Arduino IDE via WiFi (see examples)

Put the Yun Shield on top of Uno and power it via DC jack.

Connect to Arduino Duemilanove/Diecimila

1)In Duemilanove/Diecimila, the mega avr uart interface is connected to the FTDI chip, we have to disconnect them as shown in picture below:

Use with Arduino Duemilanove/Diecimila

Note: No need to remove these components in Yun Shield v1.1.6 and Yun Shield v2.4

2)Use the same Board Profile as UNO in the Arduino IDE

3)Put the Yun Shield on top of Duemilanove and power it via DC jack.

Connect to Arduino Mega2560

1)In the Mega2560, the uart connection between mega2560 and mega16u2 will influence the bridge feature of the Yun Shield. Therefore we have to disconnect it by setting the mega16u2 into reset mode. As below:

Use with Arduino Mega2560

Note: No need to put the jumper anymore in Yun Shield v1.1.6 and Yun Shield v2.4

2)Put the Yun Shield on top of Mega2560 and power it via the DC jack.

Connect to Freetronics "Eleven"

While connecting to a Freetronic "Eleven", the user can use the same profile as connecting to a UNO, but will need to do the hardware modification below, which is a little different from the Arduino Uno.

Use with Freetronics Eleven, provided by Quentin McDonald

Note: No need to put the jumper anymore and remove the component in Yun Shield v1.1.6 and Yun Shield v2.4



Connect to Dccduino UNO R3

Use with Dccduino UNO R3

Note: No need to remove these components in Yun Shield v1.1.6 and Yun Shield v2.4

Connect to Helvetino Kit

Use with a Helvetino Kit, wire the SPI to ICSP header



Connect to Teensy

The Teensy is a complete USB-based microcontroller development system and is as versatile as it is powerful. A custom Teensy installer and bridge application will easily allow you to write sketches for the Teensy and load them on to the Teensy. All programming is done via the USB port just like the Arduino - no special programmer is needed.

Click here to get more information

Use with Teensy



Detect Yun Shield

Make sure your laptop and Yun Shield are on the same network. The Yun Shield will broadcast data on this network and the Arduino IDE will receive this data and show the Yun Shield in Tools →Port.

Yun Shield is Detected in Arduino IDE



Upload Sketch

Upload via WiFi/ LAN from IDE

  • In the Arduino IDE, choose the correct board type for the AVR module.
  • In the Arduino IDE → port, choose the correct port. (Should be Arduino Yun port with an ip address)
  • In the Yun Shield GUI → Sensor page, choose the correct board type for upload.
  • Compile the sketch and upload it to the Arduino Board. During upload, the Yun Shield will ask you to key in the password, by default, the password is dragino.
Compile Sketch for Yun



Upload via Web

Upload via Web --> Sensor Page



Auto Update Sketch

For sketch auto update in the field please refer to: Manual for Auto update Sketch.



Bridge Library

The Bridge Library simplifies communication between the Arduino Board and the Yun Shield.

Bridge commands from the AVR (Arduino Board) are interpreted by Python on the Yun Shield. Its role is to execute programs on the GNU/Linux side when asked by Arduino, provide a shared storage space for sharing data like sensor readings between the Arduino and the Internet, and receiving commands from the Internet and passing them directly to the Arduino.

There are detail explanations and lots of examples to show how to use Bridge on the Arduino Official Website. Reference link is:Yun Bridge Library

Quick Start



EXAMPLES

Example 1: Say hello to Linux

Detect IP address from the Arduino IDE:

This example is a hello test between the Arduino and the Yun Shield. The example can be found at Arduino IDE--> File --> Examples --> Bridge --> ConsoleRead. A tutorial for this example can be found on http://arduino.cc/en/Tutorial/ConsoleRead. The listing of the code below includes some detail to understand it working with the Yun Shield:

Code:

#include <Console.h> //use Console class for Arduino IDE debug over WiFi, similar to Serial class,
String name;
 
void setup() {
  // Initialize Console and wait for port to open:
  Bridge.begin();
  Console.begin();
 
  // Wait for Console port to connect
  while (!Console);
 
  Console.println("Hi, what's your name?"); //Data flow: Arduino --> Yun Shield --> Arduino IDE
}
 
void loop() {
  if (Console.available() > 0) {
    char c = Console.read(); //read the next char received, data flow: IDE --> Yun Shield--> Arduino
    // look for the newline character, this is the last character in the string
    if (c == '\n') {
      //print text with the name received
      Console.print("Hi ");
      Console.print(name);
      Console.println("! Nice to meet you!");
      Console.println();
      // Ask again for name and clear the old name
      Console.println("Hi, what's your name?");
      name = "";  // clear the name string
    }
    else {  	 // if the buffer is empty Cosole.read() returns -1
      name += c; // append the read char from Console to the name string
    }
  }
}


Screen Shot:

Result



Example 2: Upload data to IoT Server

Introduction:

This example shows how to log data to the public IoT server “Xively”. The example is a modified version (changed Serial to Console to suit different Arduino Board and debug over WiFi) from Arduino IDE--> File --> Examples --> Bridge --> XivelyClient. The tutorial for this example can be found at http://arduino.cc/en/Tutorial/YunXivelyClient

Before uploading the sketch, make sure:

  • The Yun Shield already has internet access
  • Input your FEED ID and API KEY according to the tutorial. Note, the FEED ID should be within double quotation marks “”.
  • Change the Serial Class to Console class to suit different AVRs.

The code listing below includes some detail to understand it working with the Yun Shield:

Code:

// include all Libraries needed:
#include <Process.h>	//Process lib use to call Linux Commands in Yun Shield
#include <Console.h>	//Console lib, used to show debug info in Arduino IDE
#include "passwords.h"      // contains my passwords, see below
 
/*
  NOTE: passwords.h is not included with this repo because it contains my passwords.
 You need to create it for your own version of this application.  To do so, make
 a new tab in Arduino, call it passwords.h, and include the following variables and constants:
 
 #define APIKEY        "foo"                  // replace your pachube api key here
 #define FEEDID        “0000”                   // replace your feed ID
 #define USERAGENT     "my-project"           // user agent is the project name
 */
 
 
// set up net client info:
const unsigned long postingInterval = 60000;  //delay between updates to xively.com
unsigned long lastRequest = 0;      // when you last made a request
String dataString = "";
 
void setup() {
  // start console:
  Bridge.begin();
  Console.begin();
 
  while (!Console);   // wait for Network Serial to open
  Console.println("Xively client");
 
  // Do a first update immediately
  updateData();
  sendData();
  lastRequest = millis();
}
 
void loop() {
  // get a timestamp so you can calculate reading and sending intervals:
  long now = millis();
 
  // if the sending interval has passed since your
  // last connection, then connect again and send data:
  if (now - lastRequest >= postingInterval) {
    updateData();
    sendData();
    lastRequest = now;
  }
}
 
void updateData() {
  // convert the readings to a String to send it:
  dataString = "Temperature,";
  dataString += random(10) + 20;
  // add pressure:
  dataString += "\nPressure,";
  dataString += random(5) + 100;
}
 
// this method makes a HTTP connection to the server:
void sendData() {
  // form the string for the API header parameter:
  String apiString = "X-ApiKey: ";
  apiString += APIKEY;
 
  // form the string for the URL parameter:
  String url = "https://api.xively.com/v2/feeds/";
  url += FEEDID;
  url += ".csv";
 
  // Send the HTTP PUT request, form the linux command and use Process Class to send this command to Yun Shield
 
  // Is better to declare the Process here, so when the
  // sendData function finishes the resources are immediately
  // released. Declaring it global works too, BTW.
  Process xively;
  Console.print("\n\nSending data... ");
  xively.begin("curl");
  xively.addParameter("-k");
  xively.addParameter("--request");
  xively.addParameter("PUT");
  xively.addParameter("--data");
  xively.addParameter(dataString);
  xively.addParameter("--header");
  xively.addParameter(apiString);
  xively.addParameter(url);
  xively.run();
  Console.println("done!");


Screen Shot:

Result Screen Shot

Video Instruction:



Example 3: Log Data to USB flash

Introduction:

This example shows how to log data to a USB flash. The sketch used in this example is the same as Log Data to USB Flash. The source code is in this link.

The Yun Shield will auto mount the USB flash to directory /mnt/sda1. The sketch will append the sensor data to the file /mnt/sda1/data/datalog.csv. Make sure there is such file in the USB flash before running the sketch.

Code:

#include <FileIO.h>     //FileIO class allow user to operate Linux file system
#include <Console.h>   //Console class provide the interactive between IDE and Yun Shield
 
 
void setup() {
  // Initialize the Console
  Bridge.begin();
  Console.begin();
  FileSystem.begin();
 
  while(!Console);  // wait for Serial port to connect.
  Console.println("Filesystem datalogger\n");
}
 
 
void loop () {
  // make a string that start with a timestamp for assembling the data to log:
  String dataString;
  dataString += getTimeStamp();
  dataString += " , ";
 
  // read three sensors and append to the string:
  for (int analogPin = 0; analogPin < 3; analogPin++) {
    int sensor = analogRead(analogPin);
    dataString += String(sensor);
    if (analogPin < 2) {
      dataString += ",";  // separate the values with a comma
    }
  }
 
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  // The USB flash card is mounted at "/mnt/sda1" by default
  File dataFile = FileSystem.open("/mnt/sda1/data/datalog.csv", FILE_APPEND);
 
  // if the file is available, write to it:
  if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
    // print to the serial port too:
    Console.println(dataString);
  }  
  // if the file isn't open, pop up an error:
  else {
    Console.println("error opening datalog.csv");
  } 
 
  delay(15000);  //Write every 15 seconds
 
}
 
// getTimeStamp function return a string with the time stamp
// Yun Shield will call the Linux "date" command and get the time stamp
String getTimeStamp() {
  String result;
  Process time;
  // date is a command line utility to get the date and the time 
  // in different formats depending on the additional parameter 
  time.begin("date");
  time.addParameter("+%D-%T");  // parameters: D for the complete date mm/dd/yy
                                //             T for the time hh:mm:ss    
  time.run();  // run the command
 
  // read the output of the command
  while(time.available()>0) {
    char c = time.read();
    if(c != '\n')
      result += c;
  }
 
  return result;
}

Screen Shot:

Result

Example 4: Use MQTT

Introduction:

MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium. For example, it has been used in sensors communicating to a broker via satellite link, over occasional dial-up connections with healthcare providers, and in a range of home automation and small device scenarios. It is also ideal for mobile applications because of its small size, low power usage, minimised data packets, and efficient distribution of information to one or many receivers.

This example shows how to use the Yun Shield with the SSL MQTT protocol.

Install required packages

Install below packages for MQTT:

root@Arduino:~# opkg update
root@Arduino:~# opkg install libcares
root@Arduino:~# opkg install libopenssl
root@Arduino:~# opkg install libmosquitto
root@Arduino:~# opkg install mosquitto-client

Test with public MQTT test server:

test.mosquitto.org hosts a publicly available Mosquitto MQTT server/broker. The User can post and subscribe to this MQTT server for testing. To test this server with an SSL connection, the user has to download the certificate authority file mosquitto.org.crt to verify the server connection.

Open two SSH windows. In the first window, we subscribe to a topic with the command below:

 mosquitto_sub -h test.mosquitto.org -p 8883 --cafile mosquitto.org.crt -t dragino/device0/temperature

This command will listen to this topic and display any change on the server.

In the other window, we publish the change with another command:

mosquitto_pub -h test.mosquitto.org -p 8883 --cafile mosquitto.org.crt -t dragino/device0/temperature -m 31

Once the publish command is issued, we can see the result display in the subscribe command.

Example 5: Use the 3G dongle

Introduction

This is the introduction for how to use a 3G USB dongle to connect to the Yun Shield and establish the 3G connection. The firmware tested in the demo below is Dragino-v2 common-2.0.3 and the 3G USB dongle model is a HuaWei E303 using UMTS for 3G connection. The service provider is China Unicom.


Install required packages

Configure the Yun Shield to connect Internet via WiFi and install the below packages:luci-proto-3g,kmod-usb-serial-option, kmod-usb-serial-wwan usb-modeswitch-data, usb-modeswitch. The output should be as below:

root@dragino:~# opkg update
Downloading http://www.dragino.com/downloads/downloads/motherboards/ms14/Firmware/Yun/Packages--v2.x/Packages.gz.
Updated list of available packages in /var/opkg-lists/attitude_adjustment.
Downloading http://www.dragino.com/downloads/downloads/motherboards/ms14/Firmware/Yun/Packages--v2.x/Packages.sig.
Signature check passed.
root@dragino:~# opkg install luci-proto-3g
Installing luci-proto-3g (0.11+svn10537-1) to root...
Downloading http://www.dragino.com/downloads/downloads/motherboards/ms14/Firmware/Yun/Packages--v2.x/luci-proto-3g_0.11+svn10537-1_ar71xx.ipk.
Installing comgt (0.32-21) to root...
Downloading http://www.dragino.com/downloads/downloads/motherboards/ms14/Firmware/Yun/Packages--v2.x/comgt_0.32-21_ar71xx.ipk.
Installing chat (2.4.5-10) to root...
Downloading http://www.dragino.com/downloads/downloads/motherboards/ms14/Firmware/Yun/Packages--v2.x/chat_2.4.5-10_ar71xx.ipk.
Configuring chat.
Configuring comgt.
Configuring luci-proto-3g.
root@dragino:~# opkg install kmod-usb-serial-option kmod-usb-serial-wwan usb-modeswitch-data usb-modeswitch
Installing kmod-usb-serial-option (3.3.8-1) to root...
Downloading http://www.dragino.com/downloads/downloads/motherboards/ms14/Firmware/Yun/Packages--v2.x/kmod-usb-serial-option_3.3.8-1_ar71xx.ipk.
Installing kmod-usb-serial-wwan (3.3.8-1) to root...
Downloading http://www.dragino.com/downloads/downloads/motherboards/ms14/Firmware/Yun/Packages--v2.x/kmod-usb-serial-wwan_3.3.8-1_ar71xx.ipk.
Installing kmod-usb-serial (3.3.8-1) to root...
Downloading http://www.dragino.com/downloads/downloads/motherboards/ms14/Firmware/Yun/Packages--v2.x/kmod-usb-serial_3.3.8-1_ar71xx.ipk.
Package kmod-usb-serial-wwan (3.3.8-1) installed in root is up to date.
Installing usb-modeswitch-data (20120120-1) to root...
Downloading http://www.dragino.com/downloads/downloads/motherboards/ms14/Firmware/Yun/Packages--v2.x/usb-modeswitch-data_20120120-1_ar71xx.ipk.
Installing usb-modeswitch (1.2.3-2) to root...
Downloading http://www.dragino.com/downloads/downloads/motherboards/ms14/Firmware/Yun/Packages--v2.x/usb-modeswitch_1.2.3-2_ar71xx.ipk.
Package usb-modeswitch (1.2.3-2) installed in root is up to date.
Configuring kmod-usb-serial.
Configuring kmod-usb-serial-wwan.
Configuring kmod-usb-serial-option.
Configuring usb-modeswitch.
Configuring usb-modeswitch-data.
root@dragino:~#


Configure 3G info

Open the page System --> advanced configuration panel --> Network --> Interfaces. Click Add New Interface

Create 3g interface
Configure 3G Interface

Reboot the device.

3G is Up and get public IP after reboot



Video Instruction



Example 6: Save Data to Google SpreadSheet

Example inlcude lots content, please refer this link



Example 7: Save Data to MySQL

Example inlcude lots content, please refer this link



FAQ

What is the difference between the official Arduino Yun and the Yun Shield?

Hardware Aspects

The Arduino Yun and the Yun Shield have the same CPU, Memory size and RAM size for the Linux system. The Arduino Yun is an integrated Linux and MCU part. The Yun Shield is designed as a shield which can be used with existing Arduino boards.

Basically, a Yun Shield + Arduino Leonardo equal an Arduino Yun, but the Yun Shield is more flexible because it can be used with other Arduino boards such as Arduino Uno, Duemilanove, Diecimila etc.

The Yun Shield can be duplicated and is producible: The design of the Yun Shield is open and the most complicated and difficult parts are done in the Dragino HE module. The User can purchase the Dragino HE module separately to customize their IoT project and release their variant Yun Solution.

Stable and Flexible WiFi performance: The Arduino Yun uses a chip antenna design. If there is a shield on top of the Arduino Yun, the wifi will be greatly shielded and lead to a poor wifi performance. Instead, the Yun Shield uses a external antenna design. the user can connect different types of antennas to the i-pex connector of the Yun Shield: this makes the installation more flexible and possible to transfer the signal to several km distance.

Software Aspects

The Yun Shield software is derived from the Arduino Yun with some bugs fixed; features added and support more board types.

Is Yun Shield compatible with a variant Arduino Board?

If the Arduino board is a variant from the boards described in Support Board Type , then it should be compatible. Below is the check list for the compatibility.

  • The variant has 7~15v power in the VIN pin to power the Yun Shield.
  • The variant has the same definitions and positions of SPI pins in the ICSP header as the official board.
  • The variant has the same definitions and positions of D0 and D1 pins in the ICSP header as the official board.
  • Check whether there are ICs connected to the SPI and UART of the AVR and evaluate whether they will influence the communication between Yun Shield and the AVR MCU.

The system structure section well explains the working principle of the Yun Shield. If the user is still not sure whether the Yun Shield is compatible with their board or having trouble in compatibility, then they can send the board info to support@dragino.com and our support team will review and check it.

Can i use the Yun Shield with Arduino Due?

The Yun Shield provides two great features to ensure ease of use with Arduino boards, they are:

  1. Bridge Library : which uses the UART interface and Bridge library from Arduino
  2. Upload the Arduino Sketch via WiFi : which uses the Avrdude to flash the ATMEL avr chip via the SPI interface.

The above two features don't work in Arduino Due. So when using the Yun Shield with the Arduino Due, the above features won't work. As an alternative, the user can use the Yun Shield and Arduino Due and communicate via UART and SPI using a self-defined protocol.

When a developer is connecting the Yun Shield and a Arduino Due, they should notice that the 5v/3.3 IO jumper should be set to 3.3v because Arduino Due is operated at 3.3v.



How to set up /www/sd and /mnt/sd?

To use the /www/sd and /mnt/sd as the same as a Arduino Yun, the user can prepare a USB flash and create directories /arduino and /arduino/www at the root of USB flash. Then plug the USB flash into the Yun Shield and it will automatically create /www/sd and /mnt/sd and link to /arduino and /arduino/www.

Where can I find the source code of Yun Shield?

The Yun Shield source can be found at: https://github.com/dragino/linino

How to Upload, Download or Edit files in the Yun Shield

The Yun Shield has a built-in Linux system and supports the SCP protocol. The user can upload, download or edit the Linux files using SCP tools.

In a windows OS, the scp tool is winscp. Install it and log into the Yun Shield as below:

  • Host Name: Yun Shield IP address
  • User Name: root
  • Password: arduino (default)
  • Protocol: SCP
WinSCP Window

The log in process will cause two warnings: just ignore them. After log in, a management panel will appear. The left part of this panel is your PC’s directories and the right part shows the directories of the Yun Shield, you can upload/download files by dragging, or double click the files to modify its content.

WinSCP Window



How to reset the Yun Shield

The Yun Shield has a toggle button which can be used for reset. When the system of the Yun Shield is running, the user can press the toggle button to reset the device. Pressing this button will cause the WLAN LED will blink.

  • Pressing the toggle button and release after 5 seconds, will reset the WiFi setting and other settings will be kept.
  • Pressing the toggle button and release after 30 seconds, will reset ALL the setting to factory default .



How to recover the Yun Shield in case of a firmware crash

There are some cases that the Yun Shield fails to boot, for example upgrade improper firmware or lost power during upgrade. The user is still able to recover the Yun Shield system by using the Failsafe u-boot of the Yun Shield

An instruction in Windows is as below:

Set up TFTP server

Download the tftp server (recommend tftp32d.exe) and download the latest Yun firmware from Yun Firmware . The firmware we need is the kernel and rootfs-squashfs files. Put these firmware files and tftp32d in the same directory. Start the tftp server.

Download Hercules utility

Download Hercules. This is the tool we use to transfer commands to the Yun Shield in Failsafe mode. Run Hercules and input the correct parameters as below:

Hercules Window

Protocol: UDP

Module IP: 192.168.255.1

Port: 6666

Local port: 6666

Connect your PC to the Yun Shield

Connect the PC and Yun Shield via an Ethernet cable. Set up the PC with the below LAN IP 192.168.255.2 and netmask 255.255.255.0. Disable the PC’s firewall.

Power up Yun Shield to Failsafe mode

Press the Failsafe button and power up the Yun Shield; the user will see all the LEDs blink together. Release the button after 10 seconds and some messages will pop up in the Hercules panel which means the Yun Shield has been in Failsafe Netconsole mode and is ready to access commands.

The user can type the commands in Hercules to transfer and upgrade the Yun Shield to the latest firmware with factory settings.

The update commands are as below, replace the xxx with the actually version.

Note when typing command in Hercules: The user must add <CR> at the end of each command. $ is a special char in Hercules: the user should double it (key in 2, $$) when typing.

Upgrade Kernel

tftpboot 0x81000000 ms14-arduino-yun-kernel-xxx.bin
erase 0x9fea0000 +0x140000 
cp.b 0x81000000 0x9fea0000 $filesize

Upgrade rootfs

tftpboot 0x81000000 ms14-arduino-yun-rootfs-squashfs-xxx.bin
erase 0x9f050000 +0xe50000    
cp.b 0x81000000 0x9f050000 $filesize

Reset to the new firmware

reset

Video Instruction



Warning: The user should use exactly the address numbers shown in the erase and cp.b lines shown: wrong address numbers may destroy the boot-loader of the Yun Shield and the device won’t boot anymore, or destroy the radio data of the Yun Shield which may lead to a poor wifi performance or incorrect MAC addresses.

Recover in Linux is similar with Windows, the main difference is that the tool use in Linux is nc and runs with nc -kul 6666. Below shows that the Yun Shield has been in Failsafe Netconsole mode and detected by nc.

Linux Windows



How to use Yun Shield UART without an Arduino

It is possible to use Yun Shield UART without an Arduino. The diagram below shows the detail for how to connect:

Yun Shield UART connection

Notice:

  • The TXD and RXD will connect to UART_TX/UART_RX only after the level shift is enabled (GPIO24 set to high). The GPIO24 is set high in Dragino Yun OpenWrt Environment, so from TXD/RXD side, the user has no access to the u-boot bootloader UART.
  • The Dragino Yun firmware uses a 250000 BaudRate by default to match the Arduino Bridge Class. This is not a common baudrate and user will properly see mess code on the TXD/RXD. The user can set the baudrate to a desired baudrate using the stty command in OpenWrt. If the user wants to access the Linux system via UART, we suggest using the IoT Mesh Firmware which has baud rate on 115200.



Trouble Shooting

Can not see the Yun Wireless network

  • make sure that the Arduino is powered by power adapter and the input voltage is between 7v ~ 12v
  • make sure the Yun Shield has the antenna connected to its i-pex socket.
  • make sure the Yun Shield is in AP mode.



Arduino IDE doesn’t detect Yun Shield

Check the points below if this issue happens:

  • The Arduino IDE version is 1.5.4 or later
  • Your PC and Yun Shield are on the same network.
  • If the Yun Shield boots before the Arduino IDE, this may happen. So try to power off/on the Yun Shield and check again. The user can also add a domain entry to tell the Arduino IDE what IP arduino.local will point to, this will help the Arduino IDE to detect the Yun Shield. The user need not assign the same IP as the Yun Shield. For example, in Windows 7, the user can add the line below in C:\Windows\System32\drivers\etc\hosts file
10.130.2.1 arduino.local
  • If all above doesn't work, try ssh to the yun shield and run /etc/init.d/avahi-daemon restart. This will broadcast the Arduino service and Arduino IDE should get it.



The Arduino Bridge doesn't work

Hardware Possibility

The Bridge uses the UART interface from the AVR, in Arduino Boards these traces always connect the USB to the UART chip for sketch upload. If this is not so, it will prevent the bridge working as expected most of time. We have the modification examples for official or branded Arduino Boards in this link: Connects_to_Arduino_Boards. There are still lots of Arduino variant boards using different hardware. The basic concept is to make the UART as clean as possible. We also provide some work-rounds from our customers for reference as below:

Connect to Mega2560 clone with CH340G USB chip, provided by Seigei

Software Possibility

In Some Arduino models, we can't use Serial and Bridge together in the sketch. Detail reason plase check this link: Bridge doesn't work with Mega328P/Mega2560



Upload Sketch Fail

Arduino IDE shows signature mismatch

An example output from the Arduino IDE as below:

Programmer Type : linuxgpio
Description : Use the Linux sysfs interface to bitbang GPIO lines

avrdude: Calibrating delay loop... calibrated to 49 cycles per us
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9801
avrdude: Expected signature for ATmega32U4 is 1E 95 87
Double check chip, or use -F to override this check.

The above result shows that the Yun Shield tries to program the Arduino with mega32u4 mcu but actually the Arduino is based on the mega2560 which has signature 0x1e9801, so it fails. So solve this issue, the user can choose the mcu/board type to the correct one in the Yun Shield Web Interface --> Sensor --> Arduino Board type.




Yun Shield can't connect to the AVR

Typical output in the Arduino IDE for this issue is as below:

        Programmer Type : linuxgpio
        Description     : Use the Linux sysfs interface to bitbang GPIO lines
 
avrdude: Calibrating delay loop... calibrated to 48 cycles per us
avrdude: AVR device not responding
avrdude: initialization failed, rc=-1
        Double check connections and try again, or use -F to override
        this check.
 
 
avrdude done.  Thank you.

This means that there is something wrong on the SPI interface between the Yun Shield and the Arduino Board. There are two possible:

  • User doesn't power the Yun Shield properly. Check this link for how to power it right
  • Please check if the SPI connection between them is clean and doesn't have other components hooked onto it. Some components may interfere with the SPI connection.


Below is the way Yun Shield upload sketch to AVR and How to debug where is wrong:

Yun Shield Upload Sketch Structure

Check if MOSI/MISO/SCK/RESET hardware connection works as expect, below is the PIN mapping with the GPIOs. User can export the GPIOs in linux and run the commands as below to set high / low to GPIO. The related SPI pins will be high(+5V) / low accordingly and can be check by a multimeter. Low is 0v and high is 3.3v or 5v depends on the Arduino board. Below is the commands need to type and check whether GPIO works.

	echo 1 > /sys/class/gpio/gpio19/value   // enable level shift , GPIO19 will be 2.6v
 
	echo 18 > /sys/class/gpio/export     //export gpio 18
	echo "high" > /sys/class/gpio/gpio18/direction   // set direction to out and set level to high  .. GPIO18 will be 2.6V
	echo "1" > /sys/class/gpio/gpio18/value   // set this GPIO to high, SPI_SCK should be high in the ICSP header. 
	echo "0" > /sys/class/gpio/gpio18/value   // set this GPIO to low, SPI_SCK should be low in the ICSP header. 
 
	echo 21 > /sys/class/gpio/export     //export gpio 21
	echo "high" > /sys/class/gpio/gpio21/direction   // set direction to out and set level to high GPIO21 will be 2.6V
	echo "1" > /sys/class/gpio/gpio21/value   // set this GPIO to high, SPI_MOSI should be high in the ICSP header. 
	echo "0" > /sys/class/gpio/gpio21/value   // set this GPIO to low, SPI_MOSI should be low in the ICSP header. 
 
	echo 22 > /sys/class/gpio/export     //export gpio 22
	echo "high" > /sys/class/gpio/gpio22/direction   // set direction to out and set level to high GPIO22 will be 2.6V
	echo "1" > /sys/class/gpio/gpio22/value   // set this GPIO to high, SPI_MISO should be high in the ICSP header. 
	echo "0" > /sys/class/gpio/gpio22/value   // set this GPIO to low, SPI_MISO should be low in the ICSP header. 
 
	echo 20 > /sys/class/gpio/export     //export gpio 20
	echo "high" > /sys/class/gpio/gpio20/direction   // set direction to out and set level to high GPIO20 will be 2.6V
	echo "1" > /sys/class/gpio/gpio20/value   // set this GPIO to high, /RESET should be low in the ICSP header. 
	echo "0" > /sys/class/gpio/gpio20/value   // set this GPIO to low, /RERST should be high in the ICSP header.

Note: After export all the GPIOs, Yun Shield won't be able to upload sketch to Arduino unless reboot the device.


Debug Case Study

Below is a case study to solve this issue while connecting to a UNO clone board.

1/ SSH to the Yun Shield and enable the SPI connection by using commands below:

echo 19 > /sys/class/gpio/export     //export gpio 19
echo "high" > /sys/class/gpio/gpio19/direction   // set direction to out and set level to high
echo 1 > /sys/class/gpio/gpio19/value // to set high

2/ Check each SPI signal and see if they are fine. Use the GPIO configure commands as above to set high and low, then measure the ISCP headers with multimeter. We found that the SCK only had 2.9v while expected to be 5v. So we check if there is some component connected to the SCK trace in the UNO clonet, we found a LED is connected to it. So we remove the L LED from the UNO to allowed the SPI to work fine after that.




REFERENCE