YUN SHIELD

From Geeetech Wiki
Revision as of 08:47, 11 November 2014 by Admin (talk | contribs) (Upload Sketch Fail)

Jump to: navigation, search

Introduction

YUN SHIELD.jpg

Yun Shield, designed by Dragino, is one of the most powerful shields for Arduino Board on the present market. One of the main calls for the design of Yun Shield is to make up for the insufficient Internet connectivity and the storage issue for Arduino Board

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

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


Features

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

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.


POWER

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

The USB Host of Yun Shield gets power from the Arduino +5vpin, since the +5v from Arduino comes from the +5V LDO, to avoid overheated on the Arduino Board, when the USB host is in used, it is recommended to use +7v DC.


Interface

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

The SPI interface is used to upload the sketches comes from the Arduino IDE. SPI interface only connects to Dragino HE during uploading so the ArduinoSPI 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 explain how to use the bridge class in the Arduino IDE. It is the core of Yun solution. We must make sure the serial Interface of Arduino is not used by other hardware.

LEDs

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

PWR: Power Indicate LED. Turn on once there is power.

LAN: Indicate there is 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 Arduino Yun default SD directory /mnt/sd and /www/sd


A Full View of YUN Shield

Set up and use Yun Shield

Connect to Leonardoand power

Simply put the Yun Shield on the top of Arduino Leonardo and Power the Leonardo via the DC Jack.

Connect to Yun Shield

At the first boot of Yun Shield, it will auto generate an unsecure WiFi network call Dragino2-xxxxxx User can use their laptop to connectto this WiFi network. The laptop will get an IP 192.168.240.xxx andthe Yun Shield has the default IP 192.168.240.1

Yun shield 1.jpg

Once user joinsthe network, they can use web browser (recommend Firefoxand Chrome) and enter 192.168.240.1 to enter the Yun Shield setting page.

Yun shield 2.jpg

Default Password for Yun Shield is dragino.


Set Up Yun Shield to access internet

After log in,the GUI will show the WIFI / ETH interface status. Click the Configure button and now user canconfigure Yun Shield to access internet via your WiFi router.

Yun shield 3.jpg

Detect Yun Shield

Assume your laptop and Yun Shield are in the same network. The Yun Shieldwill broadcastdata in thisnetworkand Arduino IDE will receive this data and show the Yun Shield in Tools>Port.

Yun shield 4.jpg

Upload Sketch

1) In the Arduino IDE, choose the Arduino Yun board type for Leonardo.

2) In Arduino IDE port, choose the correctport. (should be ArduinoYun port with an ip address)

3) In the Yun Shield GUI Sensor page, choose the Board Type: Leonardo.


4) 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 passwordis dragino.

Yun shield 5.jpg

USE WITH ARDUINO BOARDS

The Yun Shield use SPI for uploading sketch and use UART port for Bridge class to talk to the AVR. While connects 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.

Bridge Library

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

Bridge commands from the AVR(ArduinoBoard)are interpreted by Python on theYun 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 explain and lots of example to show how to use Bridge in the Arduino Official Website. Reference link is: http://arduino.cc/en/Reference/YunBridgeLibrary.

Connects to Arduino Boards

Connect to Leonardo

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

Connect to Arduino Uno

1)In UNO, the uart connection between mega328P and mega16u2 will influence the bridge feature with Yun Shield. So we have to disconnect it by set the mega16u2 into reset mode. As below:

Yun Shield with Uno.png

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

2)Add a “Uno Yun” board type in the file: Arduino\hardware\arduino\avr\board.txt. as below and reopen the Arduino IDE:

 unoyun.name=Arduino Uno -- Dragino Yún
 unoyun.upload.via_ssh=true

 unoyun.vid.0=0x2341
 unoyun.pid.0=0x0043
 unoyun.vid.1=0x2341
 unoyun.pid.1=0x0001
 unoyun.upload.tool=avrdude
 unoyun.upload.protocol=arduino
 unoyun.upload.maximum_size=32256
 unoyun.upload.maximum_data_size=2048
 unoyun.upload.speed=57600
 unoyun.upload.disable_flushing=true
 unoyun.upload.use_1200bps_touch=true
 unoyun.upload.wait_for_upload_port=true

 unoyun.bootloader.tool=avrdude
 unoyun.bootloader.low_fuses=0xff
 unoyun.bootloader.high_fuses=0xde
 unoyun.bootloader.extended_fuses=0x05
 unoyun.bootloader.file=optiboot/optiboot_atmega328.hex
 unoyun.bootloader.unlock_bits=0x3F
 unoyun.bootloader.lock_bits=0x0F

 unoyun.build.mcu=atmega328p
 unoyun.build.f_cpu=16000000L
 unoyun.build.board=AVR_YUN
 unoyun.build.core=arduino
 unoyun.build.variant=standard


3)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 below picture:

Yun Shield with Duemilanove.png

2)Add a “Duemilanove Yun” board type in the file: Arduino\hardware\arduino\avr\board.txt. user can use the UnoYun board type if they has mega328p. for mega328/mega168/mega168p, they can modify the upload.maximum_data_size/ upload.maximum_size and build.mcu accordingly. 3)Put the Yun Shield on top of Duemilanove and power it via DC jack.

Connect to Arduino Mega2560

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

Yun Shield with 2560.png

2)Add a “Mega2560 Yun” board type in the file: Arduino\hardware\arduino\avr\board.txt. as below and reopen the Arduino IDE:

 mega2560Yun.name=Arduino Mega 2560 -- Dragino Yún
 mega2560Yun.upload.via_ssh=true

 mega2560Yun.vid.0=0x2341
 mega2560Yun.pid.0=0x0044
 mega2560Yun.vid.1=0x2341
 mega2560Yun.pid.1=0x003f
 mega2560Yun.upload.tool=avrdude
 mega2560Yun.upload.protocol=arduino
 mega2560Yun.upload.maximum_size=258048
 mega2560Yun.upload.maximum_data_size=8192
 mega2560Yun.upload.speed=57600
 mega2560Yun.upload.disable_flushing=true
 mega2560Yun.upload.use_1200bps_touch=true
 mega2560Yun.upload.wait_for_upload_port=true

 mega2560Yun.bootloader.tool=avrdude
 mega2560Yun.bootloader.low_fuses=0xff
 mega2560Yun.bootloader.high_fuses=0xd8
 mega2560Yun.bootloader.extended_fuses=0xfd
 mega2560Yun.bootloader.file=stk500v2/stk500boot_v2_mega2560.hex
 mega2560Yun.bootloader.unlock_bits=0x3F
 mega2560Yun.bootloader.lock_bits=0x0F

 mega2560Yun.build.mcu=atmega2560
 mega2560Yun.build.f_cpu=16000000L
 mega2560Yun.build.board=AVR_MEGA2560
 mega2560Yun.build.core=arduino
 mega2560Yun.build.variant=mega


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


FAQ

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

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

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

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

Stable and Flexible WiFi performance: Arduino Yun use 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, Yun Shield use external Antenna design, user can connect different type of antennas to the i-pex connector of Yun Shield, this make the installation is more flexible and possible to transfer the signal to several km distance.

In Software Aspect

The Yun Shield software is derived from Arduino Yun with some bugs fixed; feature 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 same definition and position of SPI pins in the ICSP header as the official board.

The variant has same definition and position of D0 and D1 pins in the ICSP header in the official board.

Check whether there are ICs connected to the SPI and UART of the AVR and evaluate if they will influence the communication between Yun Shield and the AVR MCU.

The system structure section well explains the working principle of Yun Shield, if user still not sure if Yun Shield is compatible with their board or having trouble in the compatibility. Then can send the board info to support@dragino.com 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 Arduino Yun, user can prepare a USB flash and create directory /arduino and /arduino/www at the root of USB flash. Then input 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 Yun Shield

Yun Shield has a built-in Linux system and support SCP protocol. User can upload, download or edit the Linux files using SCP tools. In windows OS, the scp tool is winscp. Install it and log into Yun Shield as below:

Host Name: Yun Shield IP address

User Name: root

Password: arduino (default)

Protocol: SCP

Yun Shield 21.png

The log in process will alter two warning, just ignore it. 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 Yun Shield, you can upload/download files by dragging, or double click the files to modify its content.

500px-Yun Shield 22.png

How to reset the Yun Shield?

Yun Shield has a toggle button which can be used for reset. When the system of Yun Shield is running, user can press the toggle button to reset the device.

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

How to recover the Yun Shield in case firmware crash

There are some cases that the Yun Shield fails to boot , for example upgrade an improper firmware or lost power during upgrade. User is still able to recover the Yun Shield system by using the Failsafe u-boot of Yun Shield An instruction in Windows is as below:

Set up TFTP server

Download the tftp server (recommend tftp32d.exe). And download the latest [ http://www.dragino.com/downloads/index.php?dir=motherboards/ms14/Firmware/Yun/ Yun Firmware ]. The firmware we need is the kernel and rootfs-squashfs files. Put these firmware files and tftp32d at the same directory. Start the tftp server.

Download Hercules utility

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

Yun Shield 23.png

Protocol: UDP

Module IP: 192.168.255.1

Port: 6666

Local port: 6666

Connect your PC to Yun Shield

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

Power up Yun Shield to Failsafe mode

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

User can type the commands in Hercules to transfer and upgrade 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: user must add <CR>at the end of each command; $ is a special char in Hercules, user should double it (key two $$) 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

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

Recover in Linux is similar with Windows, the mail different 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.

Yun Shield 24.png

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 below points if this issue happens:
  • The Arduino IDE version is 1.5.4 or later
  • Your PC and Yun Shield are in the same network.
  • If Yun Shield boot in advance than Arduino IDE, this may happen. So try to power off/on the Yun Shield and check again.

Arduino Bridge doesn't work

The Bridge use UART interface from AVR, in Arduino Board these trace are always connect to USB to UART chip for sketch upload. It will prevent the bridge to work as expected ini most of time. We have the modification example for official or branded Arduino Board in this link: [Yun_Shield#Connects_to_Arduino_Boards|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 working around from our customers for reference as below:

Upload Sketch Fail

Arduino IDE shows signature mismatch

an example output from 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.

Above result shows that Yun Shield try to program the Arduino with mega32u4 mcu type but actaully the Arduino is mega2560 which has signature 0x1e9801. So it fails. So solve this issue, 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 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 Yun Shield and Arduino Board. So please check if the SPI connection between them is clean and don't have other components hook on it. Some components may interfere the SPI connection.

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 below commands:

 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. The relation between Yun Shield GPIO and Arduino ISCP headers are:

 GPIO18 <----> SCK
 GPIO22 <----> MISO
 GPIO21 <----> MOSI
 GPIO20 <----> /RESET
 GPIO23 <----> SS

Use the GPIO configure commands as above to set high and low, then measure the ISCP headers with mulimeter. We find that the SCK only have 2.9v while the expected is 5v, then cut the L LED from the UNO and the SPI works fine after that.


where to get=

geeetech store