-
Notifications
You must be signed in to change notification settings - Fork 2
Dragon Board 410c WoT Tutorial (English)
This is translated version of original tutorial in Japanese (based on revision 6268848)
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.
-
Dragon Board 410c - Chip1Stop
-
AC Adaptor
- Specifications require for 12V/2A AC adaptors, but for the contents of this tutorial, 12V/1.5A adaptors also work. (Power might become insufficient when more devices become connected)
- Connector Conversion Cables
-
AC Adaptor
- 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
- Gesture Sensor - Seeed, Switch Science
- Grove I2C Output Module
- OLED (0.96 in) - Seeed, Switch Science
- 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.
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.
- 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 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.
- 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 as
dragonboard-410c-32 login:
. This is usually not recommended due to security reasons, but for the tutorial’s sake we will use the easier method.
- 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.
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).
- 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)
- 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).
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.
-
You must first connect to the Terminal, and make it operable via the command line shell
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.
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:
enterroot
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.
- Launch ttermpro.exe and us Serial and select the port. It should look something like
- 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.
- Something like
-
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.
- 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
-
When prompted to login with
dragonboard-410c-32 login:
enterroot
as username.- If the login prompt does not show, try pressing enter. Sometimes it pauses after displaying the
Connected.
message.
- If the login prompt does not show, try pressing enter. Sometimes it pauses after displaying the
-
Login is complete once you see the shell
root@dragonboard-410c-32:~#
-
First you will connect to Wi-Fi and look up your IP address.
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.
-
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, andbrd 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
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
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.
- Use above described steps to connect the Dragon Board to Wi-Fi.
- The PC you are using should be connected to the same network
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 theip addr
command on the Dragon Board beforehand as described in the above steps.
- The username for the board is
-
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:~#
.
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. \
You can transfer files from your computer using SSH (Wi-Fi) or serial console(USB).
-
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 likeroot@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), enterscp -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
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.
- 前述の手順でスクリプトの ZIP ファイルが転送できたら Dragon Board のターミナルにログインします (すでに SSH もしくはシリアルコンソールでログイン済みであればそのターミナルを開きます
-
unzip gecko-embedded-scripts-master.zip
で gecko-embedded-scripts リポジトリのファイルを展開します。 -
cd gecko-embedded-scripts-master/grove-samples
で Grove を使ったサンプルスクリプトのディレクトリに移動します
サンプルスクリプトのディレクトリ には以下のファイルが含まれています
- index.js
- ボタン、LED、ジェスチャーセンサー、OLCD パネルを使ったサンプルコードを動かすサーバスクリプトです。
- package.json
- express など依存ライブラリを管理するためのパッケージ情報ファイルです。
- lib/
- ライブラリの JavaScript ファイルを収めたディレクトリです。
- public/
- index.js でホストする、localhost サーバの静的コンテンツを収めたディレクトリです。
- test/
- 各デバイスのテストコードが収められたディレクトリです。
- test/adc.js
- I2C 端子に ADC とアナログセンサーを繋いで入力値をループ出力するコードです。
- test/button-led.js
- GPIO 端子のボタンを押すと GPIO 端子の LED が光るテストコードです。
- test/gesture-oled.js
- I2C 端子のジェスチャーセンサーに応じて GPIO 端子の LED が光るテストコードです。
- test/gpio-input.js
- GPIO 端子の入力値をループ出力するテストコードです。
- test/gpio-output.js
- GPIO 端子の出力をオンオフ繰り返すテストコードです。
- (上記手順で Dragon Board のターミナルに接続して grove-samples ディレクトリに移動します)
-
npm install
コマンドを package.json ファイルの存在する grove-samples ディレクトリで実行すると、必要となる依存ライブラリが自動的にインストールされます。
- (上記手順で Dragon Board のターミナルに接続して grove-samples ディレクトリに移動します)
-
node index.js
コマンドを実行すると Node サーバが起動します - HDMI ディスプレイを接続している場合は Dragon Board のデスクトップを右クリックして Internet ⇒ Firefox を起動して http://localhost:3000/ にアクセスすることでサーバにアクセスできます。
- 同一ネットワークのパソコンからは http://192.168.11.3:3000/ でアクセスできるようになります。
- ボードでは avahi-daemon も動作しており mdns での名前解決も可能です。同一ネットワーク上に複数のボードがない環境であれば http://dragonboard-410c-32.local:3000/ などで接続することも可能です。
- ブラウザに public ディレクトの中身が表示されることを確認してください
- Ctrl+C キーで node サーバを終了させます
Grove システム のモジュールを利用するサンプルスクリプトを動かしてみましょう。
-
Hello Sensors World
- Grove のボタン (GPIO Input) モジュールを G3 (G pin) 端子 (垂直、中央付近 USB ポートより) に接続します。
- Grove の LED (GPIO Output) モジュールを G2 (E pin) 端子 (水平、中央付近 USB ポート上) に接続します。
- 前述の通り Dragon Board 上の grove-samples ディレクトリで
node test/button-led.js
を実行し node スクリプトを起動させます。 - Grove ボタンを押したら LED が点灯することを確認します。
- Dragon Board 上で Ctrl+C キーを押して node を停止させます。
-
ADC とアナログセンサーを使ってみる
- Grove の ADC (I2C) モジュールを P8 端子 (水平、HDMI ボートの上) に接続します。
- ADC モジュールのコネクタのうち、裏面に SCL, SDA, VCC, GND と書かれている方が I2C 端子で、ボードの P8 端子に接続する側です。
- Grove の光センサー (アナログセンサー) モジュールを ADC モジュールに接続します。
- ADC モジュールのコネクタのうち、裏面に GND, VCC, NC, SIG と書かれている方にアナログセンサーを接続します。
- 前述の通り Dragon Board 上の grove-samples ディレクトリで
node test/adc.js
を実行し node スクリプトを起動させます。 - 1 秒毎にセンサーの電圧値を取得して表示されます。センサーを手で覆ったりして暗くすると値が変わることを確認します。
- Dragon Board 上で Ctrl+C キーを押して node を停止させます。
- Grove の ADC (I2C) モジュールを P8 端子 (水平、HDMI ボートの上) に接続します。
-
Express を使った Node サーバを使ってみる
- Grove のボタン (GPIO Input) モジュールを G3 (G pin) 端子 (垂直、中央付近 USB ポートより) に接続します。
- Grove の LED (GPIO Output) モジュールを G2 (E pin) 端子 (水平、中央付近 USB ポート上) に接続します。
- Grove のジェスチャーセンサーモジュールを P8 端子 (水平、HDMI ボートの上) に接続します。
- Grove の OLED モジュールを P11 端子 (垂直、P8 端子の隣) に接続します。
- 前述の通り Dragon Board 上の grove-samples ディレクトリで
node index.js
を実行し、node サーバを起動させます。 - パソコン側から http://192.168.11.3:3000/ に接続して各ページで動作を確認します (URL の IP アドレスは各自のボードのもので読み替えます)
- Dragon Board 上で Ctrl+C キーを押して node を停止させます。