Skip to content

Dragon Board 410c WoT Tutorial (English)

Taichi Isaku edited this page Dec 7, 2016 · 5 revisions

This is translated version of original tutorial in Japanese (based on revision 6268848)

WoT Tutorial using the Dragon Board

About This Tutorial

This tutorial allows readers to experience development using hardware devices in the age of Web or Things (or IoT). The walkthrough should give readers an idea of what it means to connect the Reality (input/output using sensors and hardwares) with the Virtual (displaying objects on the browser screen) added with the spice of Networks (linking with servers to connect with internet services).

With the provided environment and sample codes, not only Web developers, but even students with basic knowledge on the Web (HTML/CSS/JavaScript) can easily prototype WoT devices. The tutorial also provides sufficient knowledge on the hardware side so that even those without prior knowledge on soldering or circuit design can start.

This tutorial is perfect for those interested developing embedded devices using browser technology covered by Project GEM (Gecko Embedded). Use as classroom material in schools is also welcome.

Materials Needed

  • Dragon Board 410c - Chip1Stop
  • Grove Mezzanine Board (96 Boards Sensors) - Switch Science
  • Grove GPIO Input Module (Any of the following)
    • Digital ON/OFF input module. In the tutorial we will use a button module. Whenever the tutorial requires for the button to be pressed, please perform the corresponding action for your choice of input module (light, motion, touch, etc.)
    • Buttons - Seeed, Switch Science
    • Tilt Switch - Seeed, Switch Science - one for flip, turn, etc. instead of tilt.
    • Touch sensors - Seeed, Switch Science
  • Grove GPIO Output Module (Any of the following)
    • Modules capable of digital output of ON/OFF signals. The tutorial will use ab LED bulb. Whenever the tutorial indicates the on/off of the LED, please look for the output corresponding to the module of your choice.
    • LED (red) - Seeed, Switch Science
    • Buszzer - Seeed, Switch Science
  • Grove ADC Module
    • An I2C module for reading values from analog sensors. We will connect analog sensors via an ADC module.
    • ADC (Analog to Digital Converter) - Seeed, Switch Science
  • Grove Analog Sensor (any of the following)
    • The tutorial will use a light sensor - please provide the corresponding sensation whenever we talk about shining light on the sensor.
    • Light Sensor - Seeed, Switch Science
    • Temperature Sensor- Seeed, Switch Science
    • Moisture Sensor - Seeed, Switch Science - for reading soil moisture, water depth, etc.
  • Grove I2C Input Module
  • Grove I2C Output Module
  • KVM Device Set (Unneeded if developing using remote connections via USB/WiFi)
    • HDMI Display, HDMI cable (full size)
    • USB Keyboard, USB Mouse
  • micro USB connector cable (Needed only for rewriting OS images and when using HDMI displays)
    • Not to be mixed with cables capable of charging only.

For this tutorial we will use the Dragon Board, which is an embedded that can run Linux using SoC purchasable at a relatively low price. It can be used safely since it meets Japanese national standards . For more on the Dragon Board, please visit the developing board’s pag.

For peripherals we will use modules by Grove Systems or the sake of simplicity. Sensors and devices can be plugged in directly to the low speed expansion connector GPIO/I2C port, but the Grove can easily connect devices that communicate with both digital and analog signals, UART, and I2C by standardizing the size of the connectors, cables, and the board. The board is also useful for when prototyping with Arduino or Raspberry Pi.

Preparation

The Dragon Board ships with the Android OS preinstalled, but for this tutorial we will be using the board with the Yocto Linux build overwritten. Please look through the Notes on the Dragon Board 410c page especially the section on Steps for overwritng OS Image to prepare for the tutorial.

Basic Controls

Global Operations

  • Power on/off
    • To turn on the board, you must connect it to power with the AC adaptor. The board will not work with electric power via the micro USB cable port.
      • The board has a different size port than normal AC adaptors, so a connector conversion cable may be needed.
    • To power on, insert the AC adaptor cable to the board. The Firefox on Yocto Project (Linux) image will turn on automatically when the cable is connected. The LED for PWR and RESET should turn on once connected. If no LED turns on, you should check if the power is connected correctly.
    • To power off, disconnect the AC adaptor cable from the board. Since the board will reboot automatically, close Firefox and Node and check that no saving process to the RAM/SD is happening before you unplug the cable.

To log in remotely via SSH or serial console

  • To log in using a serial console via micro USB, or to log in using SSH via WI-Fi, login as root user when asked to login with prompts such asdragonboard-410c-32 login: . This is usually not recommended due to security reasons, but for the tutorial’s sake we will use the easier method.

To use a display, mouse, or keyboard

  • When you turn on the board, you should see the Linux desktop logged in with the root user.
  • To launch an application:
    • Applications can be launched via the right-click menu on the desktop. Firefox can be located on the menu “Internet” → “Firefox.” To launch Terminal, select “Terminals” → “Xterm.” The menu contains other applications, but they will not launch since this build only contains minimal contents.
  • To switch workplaces:
    • When you scroll vertically on the desktop (when the mouse pointer is not over a window), you can switch between 4 workplaces. Caution you may accidentally switch workplaces with an unintended scroll using the mouse wheel.

Connecting the Grove D mezzanine board and modules

Here we will show how to attach the Grove mezzanine board onto the Dragon Board, and then connect modules to it. Make sure you connect modules onto the Grove board using the correct port since there are multiple ports with the same form but with different voltage (5V and 3.3V) or connection methods (digital, analog, UART, I2C).

Attaching the Grove mezzanine board(96 Boards Sensors)

  • Attach the 4-set spacers onto the 96 Boards Sensors (the mezzanine board):
    • Insert screws through the holes on the mezzanine board from the front side (the side with connectors), and hold screw on the hexagon spacers from the back side.
  • using the J8 connector (the low-speed mezzanine connector: the black connector with holes for 2 rows of 20 pins)

Connecting Grove modules

  • Connect the Grove button to the G3 port (the white, perpendicular USB port near the center) on the 96 Boards Sensors using the included cable.
    • The Grove button may have a cover on the cable, this must be removed before connecting.
    • Any GPIO digital input device of your choice can be used instead of the button.
  • Connect the Grove LED to the G2 (EF) port (the beige, horizontal port above the center USB port) using the included cable.
    • The Grove LED is packaged with the board and LED disconnected: make sure you connect it in the correct direction. The circle on the board is not a perfect circle, but has an opening on the side that the cable goes in. You can find the same semicircle on the LED too, so match the openings to connect correctly.
    • Any GPIO output device of your choice can be used instead of the LED.
  • The position of the GPIO port to connect to depends on the port number you specify on the JavaScript code. You can use any other GPIO port as long as it is not the port for I2C devices and has the correct voltage (5V or 3.3V).

Preparing the Developing Machine

To log in using micro USBs or via Wi-Fi onto the Dragon Board shell, you must prepare the serial console client so that the ssh/scp command can be used. The ssh command is used to log on safely onto the device’s shell (terminal), and the scp command is used to transfer files between devices using SSH (like when you use the cp command).

  • On Mac OS

    • You will use standard cu commands and ssh/scp commands for the OS. No installation of software is needed.
    • No installation of drivers are needed neither.
  • On Windows

    • Install the Terminal emulator Tera Term .
    • Install the driver for the serial console
      • Visit the Driver Page and download the device driver for Windows .

      • Attach the 96 Boards Sensors onto the Dragon Board and turn on the power.

      • Connect the 96 Boards Sensors to your PC via the micro USB port.

      • When Windows detects a new device and the wizard to install a driver prompts, choose the option to select a driver on the computer, and select the unzipped zip file you downloaded earlier.

        • If the wizard does not pop up, open the Device Manager (Control Panel → Hardware and Sounds). Right-click the FT230X 96Boards Console, and choose to update driver software. Choose the unzipped zip file you downloaded earlier.
      • The device should be recognized by the computer as a USB Serial Converter, and the computer should also discover new USB Serial Ports. Right-click on it, and update the driver software using similar steps.

      • When the USB Serial Port is recognized and a port number (something like COM3) is given, installation is complete.

Booting the Dragon Port Terminal

You must first connect to the Terminal, and make it operable via the command line shell

Booting Terminal directly from the board (for when you have a display)

If you have an HDMI display connected, it is virtually the same as when you are logged onto any Linux computer (though there’s no taskbar and everything). When you power on the device, it automatically logs in as the root user. Right -click on the mouse and select Terminals → Xterm.

Booting Terminal via an USB serial console (for when you don’t have a display)

The 96 Boards Sensors can be used as a USB serial console when connected to a PC via micro USB. The micro USB port on the Dragon Board can not be used as a serial console. If you do not have a 96 Boards Sensors, you must either have a SSH connection set up with a Wi-Fi connection, or have an HDMI display.

  • Connect the 96 Boards Sensors to your PC using the micro USB connector.
    • Make sure you use the port on the mezzanine board - the micro USB port on the Dragon Board can not be used as a serial console.
  • On Windows using Tera Term :
    • Launch ttermpro.exe and us Serial and select the port. It should look something like COM3: USB Serial Port (COM3).
    • Open "Serial Port… " from the Setup menu and change the Baud Rate to 115200.
    • When prompt to login with something like dragonboard-410c-32 login: enter root for the username.
      • If this doesn’t show, keep the Dragon Board connected via USB and reboot it (unplug and replug). After the Linux boot process log shows, the login prompt should show. (if the booting process shows but the login prompt doesn’t try pressing Enter).
    • Login is complete once the root@dragonboard-410c-32:~# shell displays.
  • On Mac OS:
    • Display tty device list with ls /dev/tty.*

      • Something like /dev/tty.usbserial-DACRG7O will show up on the list but its value will differ between machines. Choose the device that shows up on your mac.
    • Set connection speed to 115200, and use the device name shown in the previous step to connect to the serial console: sudo cu -s 115200 -l /dev/tty.usbserial-DACRG7O

      • Connection speed must be specified using the -s option for it to work
      • It will display Connected. but this only means that the computer is ready to work as a connection port, and does not have to do with if there is a device connected to the USB cable - it will show even if the bord power is off or if you haven’t logged into the board shell yet.
    • When it prompts Password: , enter your password to login to your mac user account.

      • To use this command you will need to have the Administrative role on the Mac device, and will need the password for an administrative account to use the sudo command.
    • When prompted to login with dragonboard-410c-32 login: enter root as username.

      • If the login prompt does not show, try pressing enter. Sometimes it pauses after displaying the Connected. message.
    • Login is complete once you see the shell root@dragonboard-410c-32:~#

Initializing the Dragon Board

First you will connect to Wi-Fi and look up your IP address.

Connecting to Wi-Fi

We will connect to Wi-Fi using the nmtui command. Make sure you have an Wi-Fi network that has an open SSID and does not filter connections between connected devices. You can also use your smartphone to create a personal hotspot and use that network.

  • (Use the above described steps to connect to the Dragon Board Terminal.)

  • Enter the nmtui command. This will let you connect to a Wi-Fi network using a simple text-based GUI.

  • Select Activate a connection and select the SSID for the network you want to use.

  • When the Authentication required by wireless network dialogue shows, enter the Wi-Fi password and select “Quit.”

  • The nmcli device status lets you see the list of networks you are connected to. The STATE of wlan0 for your network should show “connected.” す。

    root@dragonboard-410c-32:~# nmcli device status
    DEVICE  TYPE      STATE      CONNECTION
    wlan0   wifi      connected  mozilla1
    lo      loopback  unmanaged  --
    sit0    sit       unmanaged  --
    
  • Use a command such as ping github.com to check to see if you are connected to the Internet.

Checking your IP address

  • Execute command ip addr . This should show your IP network information like the example shown below. Check the IPv4 address (the inet value) for the Wi-Fi network (wlan0). For the example shown below, this will be192.168.11.3 The /24 after the address is the sub-netwrok mask, and brd 192.168.11.255 shows the boradcast address.

    root@dragonboard-410c-32:~# ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1
       link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
       inet 127.0.0.1/8 scope host lo
          valid_lft forever preferred_lft forever
       inet6 ::1/128 scope host
          valid_lft forever preferred_lft forever
    2: sit0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1
       link/sit 0.0.0.0 brd 0.0.0.0
    3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq qlen 1000
       link/ether 02:00:27:ed:2d:20 brd ff:ff:ff:ff:ff:ff
       inet 192.168.11.3/24 brd 192.168.11.255 scope global dynamic wlan0
          valid_lft 172295sec preferred_lft 172295sec
       inet6 fe80::27ff:feed:2d20/64 scope link
          valid_lft forever preferred_lft forever
    

Setting a password for the root user (optional)

When connecting the Dragon Board to a shared network, there is a chance that someone (either maliciously or accidentally) connect to your board. To prevent this, you can set a password for the root account of your board. Once you set a password, the board will prompt for the password when you connect to it via a serial console or SSH.

  • Enter command passwd
  • Enter a password of your choice. It will prompt for the same password twice for confirmation.
    root@dragonboard-410c-32:~# passwd
    Enter new UNIX password:
    Retype new UNIX password:
    passwd: password updated successfully
    

Connecting to the Dragon Board using SSH (via Wi-fi)

You can log onto your Dragon Board Terminal via Wi-Fi using SSH. To do this, both devices must be connected to the same network.

Connect the Dragon Board and Mac to the same network.

  • Use above described steps to connect the Dragon Board to Wi-Fi.
  • The PC you are using should be connected to the same network

Logging onto the Dragon Board with SSH (using command line)

These steps are for using MSYS or Cygwin on Windows or using ssh on the command line in Mac/Linux environments.

  • Open a new terminal window/tab on your computer. This should not be the terminal that is connected to the Dragon Board.

  • Enter ssh root@192.168.11.3 , i.e your Dragon Board username before @ and your IP address after.

    • The username for the board is root . You should have check the board’s IP address using the ip addr command on the Dragon Board beforehand as described in the above steps.
  • When connecting with SSH for the first time, the server(board) fingerprint will show, so enter yes . This will happen every time your IP address changes.

    $ ssh root@192.168.11.3
    The authenticity of host '192.168.11.3 (192.168.11.3)' can't be established.
    ECDSA key fingerprint is SHA256:VIHbNtrjqWmp3iC27tZtqhAvC3ZSLQ/8GXiKuRZYnJ0.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '192.168.11.3' (ECDSA) to the list of known hosts.
    Last login: Tue Nov  8 02:17:52 2016 from 192.168.11.2
    root@dragonboard-410c-32:~#
    
    • If you set a password for the Dragon Board root user, it will prompt for it.
    • Login is complete once you see shell root@dragonboard-410c-32:~# .

Logging onto the Dragon Board with SSH (using tera Term)

These are steps for using Tera Term on Windows to login.

  • Install the Terminal emulator Tera Term .
  • Open ttermpro.exe from the explorer, and enter the IP address for the Dragon Board in the “Host” box for TCP/IP.
  • Check that SSH is selected for Service.
    • If this is your first time logging in, it will show SECURITY WARNING with the server host fingerprint. Continue.
  • Enter the Dragon Board username (root) and password (if you didn’t set one up, leave it blank) and click OK .
  • Login is complete once the root@dragonboard-410c-32:~# shell displays. \

Transferring the Sample Script

You can transfer files from your computer using SSH (Wi-Fi) or serial console(USB).

Transferring files via Wi-Fi using scp (recommended)

  • You can find sample scripts from the gecko-embedded-scripts repository in the grove-samples directory.

  • Download the entire repository as a zip. (If using git clone, zip the contents into a single file, or copy the entire directory instead of single files when performing the below transfer)

  • Open a new Terminal window/tab on your computer. This should not be the terminal that is connected to the Dragon Board.

  • Enter command scp gecko-embedded-scripts-master.zip root@192.168.11.3:~ to transfer the zip file to the Dragon Board home directory. *The scp command (like the cp command) requires both the origin and destination directory for its arguments, but you can add a line like root@192.168.11.3: with the username and IP address of the remote server followed by a : o specify directories and files on a remote server. In this case the destination directory is specified as ~ or the home directory. *To copy an unzipped folder or a folder that you cloned with git clone (instead of single files), enter scp -r gecko-embedded-scripts-master/grove-samples root@192.168.11.3:~/gecko-embedded-scripts-master ith the original directory and the -r option for the new directory.

    $ scp gecko-embedded-scripts-master.zip root@192.168.11.3:~
    gecko-embedded-scripts-master.zip          100% 9802     9.6KB/s   00:00
    

Transferring files via USB cables with serial console

You can also transfer files using micro USB cables, but steps to do so will not be described here. If you do not have a Wi-Fi connection, you can check pages like http://d.hatena.ne.jp/hirose31/20060910/1157901142 for instructions.

Running Node on the Dragon Board

Running sample scripts

  • Once you have transferred the zip file using the above steps, log onto the Dragon Board terminal. (If you’re already logged on in a different window/tab open the corresponding terminal)
  • Unzip the gecko-embedded-scripts repository with unzip gecko-embedded-scripts-master.zip .
  • Move to the Grove sample scripts directory with cd gecko-embedded-scripts-master/grove-samples .

The sample script directory includes the below listed files:

  • index.js
    • A server script to run sample codes using buttons, LED, gesture sensors, and OLCD panels.
  • package.json
    • A package information file to manage dependent libraries such as express.
  • lib/
    • Directory containing JavaScript for the library.
  • public/
    • Directory containing static contents of localhost servers to host on index.js.
  • test/
    • Directory containing test codes for devices.
    • test/adc.js
      • A code to connect ADC and analog sensors to I2C and loop export inputs.
    • test/button-led.js
      • A test code that lights the LED connected to the GPIO port when the button connected to the GPIO port is pressed.
    • test/gesture-oled.js
      • A test code that lights the GPIO connected LED based on the I2C port Gesture sensor.input
    • test/gpio-input.js
      • A test code that loop exports GPIO port inputs.
    • test/gpio-output.js
      • A test code that loop between off/on for the GPIO output.

Installing node module

  • (Use the above steps to connect to the Dragon Board Terminal and move to the grove-samples directory)
  • When the npm install command is used in the grove-samples directory containing the package.json file, it will automatically install necessary dependent libraries.

Booting the node server (index.js)

  • (Use the above steps to connect to the Dragon Board Terminal and move to the grove-samples directory)
  • Boot the Node server with commandnode index.js .
  • if you have an HDMI display connected, right-click on the Dragon Board desktop and choose Internet ⇒ Firefox. Go to http://localhost:3000/ to access the server.
  • Computers connected to the same network can access from http://192.168.11.3:3000/ .
  • The board is running avahi-daemon, so you can solve names using mdns. If you do not have other boards connected to the same netowrk, you can also use http://dragonboard-410c-32.local:3000/ to connect.
  • Check to see if the browser is displaying the contents of the public directory.
  • End the node server with the Ctrl+C key.

Use the Grove module.

We will run a sample script using the Grove system module.

  • Hello Sensors World

    • Connect the Grove button (GPIO Input) module to the G3 (G pin) port (perpendicular, USB port near the center) .
    • Connect the Grove LED (GPIO Output) module G2 (E pin) port (horizontal, above the center USB ports) .
    • Use the above steps to run node test/button-led.js on the grove-samples of the Dragon Board, and boot the node script.
    • Check to see the LED lights when the Grove button is pressed.
    • Press Ctrl+C on the Dragon Board to stop node.
  • Using ADC and analog sensors

    • Connect the Grove ADC (I2C) module to the P8 port (horizontal, above the HDMI port) *The side with SCL, SDA, VCC, GND scribed on the back side is the I2C port on the ADC module. This side connects to the board's P8 port.
    • Connect the Grove light sensor (or any analog sensor) module to the ADC module.
      • Connect it to the side of the ADC module with GND, VCC, NC, SIG scribed on the back.
    • Using the above described steps, run node test/adc.js on the Dragon Board's grove-samples directory to run node script.
    • This will display the voltage from the sensor every 1 second. You should be able to see its values change when you cover the sensor with your hands.
    • Press Ctrl+C on the Dragon Board to stop node.
  • Test Node servers using Express

    • Connect the Grove button (GPIO Input) module to the G3 (G pin) port (perpendicular, USB port near the center) .
    • Connect the Grove LED (GPIO Output) module G2 (E pin) port (horizontal, above the center USB ports) .
    • Connect the Grove ADC (I2C) module to the P8 port (horizontal, above the HDMI port)
    • Connect the Grove light sensor (or any analog sensor) module to the ADC module.
    • Using the above described steps, run node test/adc.js on the Dragon Board's grove-samples directory to run node script.
    • Access http://192.168.11.3:3000/ on your PC and check to see each page working. (Make sure you use your board's IP address for the URL)
    • Press Ctrl+C on the Dragon Board to stop node.
Clone this wiki locally