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:

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

Connect to Arduino DUE

The Arduino Due is a 3.3v Arduino base on ATSAM MCU. When connecting the Yun Shield to Arduino Due, user should notice:

  • When using Yun Shield version < v1.1.6 or version <2.4, User should put the I/O voltage Jumper to 3.3v.
  • User can’t upload sketch via WiFi, instead, User has to upload sketch to DUE use the via the DUE native USB port. (board and port both select: Arduino Due(Native USB port))
  • Bridge between DUE and Yun Shield works. Be aware if use console to see result in serial monitor. User should select port to Yun Shield port instead of Arduino Due USB port.

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 medicine providers like the sellers of thc cartridges, 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

Notice About the configuration

When configure 3G info, we have to choose the right ttyUSB port for dial up. If it possible you can’t see the ttyUSB port , especially in the Yun Shield v2.x version, becasue there is more than one USB device there. We can use the lsusb command to get the usb info. as below, we can see the 3G module we have here has the info 05c6:9090.

root@dragino-162124:~# lsusb 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 058f:6254 Alcor Micro Corp. USB Hub
Bus 001 Device 003: ID 058f:6366 Alcor Micro Corp. Multi Flash Reader
Bus 001 Device 004: ID 05c6:9090 Qualcomm, Inc.

then put this line in the file /etc/module.d/60-usb-serial

usbserial vendor=0x05c6 product=0x9090

reboot the device, and the ttyUSB port will appear.

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 [email protected] and our support team will review and check it.

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 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 dragino2-yun-common-v2.0.3-kernel.bin
erase 0x9fea0000 +0x140000 
cp.b 0x81000000 0x9fea0000 $filesize

Upgrade rootfs

tftpboot 0x81000000 dragino2-yun-common-v2.0.3-rootfs-squashfs.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

Note: We have improvement on Yun Shield v1.1.6 and Yun Shield v2.4 level shift part, So this issue should not happen

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.

Arduino doesn’t work with Arduino IDE without YunShield

In the Yun Shield Web UI, there is a option Upload BootLoader in the sensor page. When this option is uncheck, the Yun Shild will ignore the Arduino bootloader when uploading the Sketch. so the Arduino won’t have bootloader after upload. In this case, if user remove the Yun Shield and use the Arduino with Arduino IDE directly, it won’t work. So user need to check upload bootloader if want to use the Arduino seperate with the Arduino IDE

REFERENCE

Use with Teensy