Demo starter application to connect WiGo to NSP and expose on-board sensors

Dependencies:   NVIC_set_all_priorities cc3000_hostdriver_mbedsocket mbed nsdl_lib TEMT6200 TSI Wi-Go_eCompass_Lib_V3 WiGo_BattCharger

Setup Guide for the IoT World Hackathon

Setup and Usage Guide for the ARM, Avnet, and Freescale platform at the IoT World Hackathon

These instructions are online at the mbed project:

http://mbed.org/teams/MBED_DEMOS/code/IoT_World_Hackathon_WiGo_NSP_Demo/wiki/Setup-Guide-for-the-IoT-World-Hackathon

Step 1. Unpack and assemble the Wi-Go kit

Starting with a new Wi-Go kit out of the box:

Follow the printed instructions included with the Wi-Go kit steps 1 through 6 only: assemble the Wi-Go and battery, plug into USB, charge battery, and check tilt sensor app by tilting or shaking the board and observing the LED change color.

Step 2. Get an mbed account

If you don’t already have an mbed account, go to http://mbed.org/ and create a free account for yourself.

The mbed platform is a web based IDE and platform for creating connected and embedded software projects for ARM based microcontrollers (MCU). The IDE runs entirely on the web and downloads a binary file to your computer that you drag and drop to your mbed device, which appears as a storage drive when connected via USB. There is no software to install on your computer to use mbed. A serial terminal emulator is useful to monitor diagnostic information from the mbed libraries and from your application program.

Step 3. Update the firmware on the FRDM KL-25Z to mbed enable the Wi-Go

This firmware update installs the basic mbed loader onto the board so mbed can be used to drag and drop program the board. It only works as tested with a Windows 7 based PC. There may be other ways, but there will be a Windows PC available at the event to perform this first update. After that, you can use the platform of your choice.

As per the KL25Z mbed firmware update page, http://mbed.org/handbook/Firmware-FRDM-KL25Z , using a PC running Windows 7, enter bootloader mode and update the firmware with the mbed binary:

  1. Power the Wi-GO off
  2. Hold the reset button down
  3. Power the Wi-GO on, them release the reset button
  4. Drive called “Bootloader” shows up as a mass storage device
  5. Drag and drop the OpenSDA mbed interface file to the Bootloader drive
  6. When done (a few seconds), power the Wi-Go off and on again
  7. A drive called “Mbed” should appear, indicating that the Wi-Go is ready for mbed programming, and can now be programmed by PC, Mac, or Linux system

The Wi-Go firmware and demos make use of the USB serial port for setup and diagnostics. It is helpful to monitor the serial port output when performing initial setup and demo testing.

Step 4. Update the Wi-Go and cc3000 firmware

Next, perform the Wi-Go firmware update as described on the Wi-Go mbed page: http://mbed.org/components/Avnet-Wi-Go-System/

  1. Drag and drop the Wi-Go Firmware Update.bin file to the mbed drive
  2. When done (a few seconds), power the Wi-Go off and on again
  3. Open a terminal application connected to the USB serial port, baud rate = 115,200
  4. Type the single character ‘Y’; board responds: “DO NOT POWER OFF Wi-Go WHILE RED LED IS ON!”
  5. Observe the LED light red for a couple of minutes. Don’t interrupt the process until the LED flashes green
  6. Turn the Wi-Go power off and on again
  7. LED should light blue and mbed drive should be detected again The Wi-Go is now ready for mbed application programming.

Step 5. Install the IoT World Hackathon Demo Application

The IoT World Hackathon Demo project: https://mbed.org/teams/MBED_DEMOS/code/IoT_World_Hackathon_WiGo_NSP_Demo/ is based on the Wi-Go IoT demo application at: https://mbed.org/users/frankvnk/code/Wi-Go_IOT_Demo_MKII/ But has the ARM Sensinode LWM2M client integrated as the red color selection on the touch slide control.

  1. Go to the project page at: https://mbed.org/teams/MBED_DEMOS/code/IoT_World_Hackathon_WiGo_NSP_Demo/
  2. Import the IoT World Hackathon demo using the “Import this program” button on the project page.
  3. Compile the project. Sometimes the “Compile All” option of the pull-down Compile menu is needed. Some compiler warnings may be expected, further directions will be given at the event. If successful, a file named IoT_World_Hackathon_WiGo_NSP_Demo_KL25Z.bin will be stored in your default location, e.g. Downloads folder.
  4. Drag and drop the compiler output file to the Wi-Go device
  5. When done copying (a few seconds), reset the Wi-Go.
  6. Status messages are available by connecting a terminal application to the USB serial port, baud rate = 115,200
  7. Configure the Wi-Go to associate with a WiFi access point using TI SmartConfig (see Note below).
  8. On restart after successful WiFi association, the WiGo should be able to run the LWM2M demo, to automatically register with the ARM Sensinode instance on the local network, and be readable by using the demo web application at http://192.168.1.220:8083/
  9. For directions on running the WiGo demo application and connecting with the the ARM Sensinode platform, see “Connect the Wi-Go to the ARM Sensinode platform” below.

Note: The Wi-Go IoT demo starts in SmartConfig mode on it’s first time configuration (FTC) and must be configured to associate with a WiFi access point before proceeding. To configure the Wi-Go with the local WiFi SSID and password, use the TI SmartConfig app on an iOS or Android smartphone. PC and Mac users can run a Java app: http://processors.wiki.ti.com/index.php/CC3000_Smart_Config

Step 6. Connect the Wi-Go to the ARM Sensinode platform

After successfully installing the IoT World Hackathon demo and configuring the WiFi networ connection using SmartConfig, the Wi-Go kit is ready to connect to the ARM Sensinode platform.

1. Reset the board. After a few seconds the LED should flash green and orange indicating ready for menu selection. Slide your finger tip across the rectangular outline on the board and watch the LED change color. When the desired selection color is showing, release your finger. If the selection color changes after you release your finger, you have 3 seconds to try again. If the wrong selection occurs, simply reset the board and try again.

RGB LED Color - Application to Launch

Orange - Erase all wireless profiles

Purple - SmartConfig

Blue - WebServer

Red - ARM Sensinode LWM2M Client

Green - Android Server

If you’re monitoring the USB serial output, you should see the following output when the LED flashes Green/Orange:

-----

CC3000 Wi-Go IOT ARM Sensinode demo.

SP Version (TI) : 1 19 0 0 4

MAC address + cc3000 info

MAC address 00:37:6d:75:68:de

FTC 1

PP_version 3.4

SERV_PACK 1.11

DRV_VER 7.13.19

FW_VER 7.12.14

Use the slider to start an application. Releasing the slider for more than 3 seconds will start the chosen application. Touching the slider within the 3 seconds timeframe allows you to re-select an application.

The RGB LED indicates the selection:

ORANGE - Erase all profiles.

PURPLE - Force SmartConfig.

BLUE - Webserver displaying live sensor data.

RED - ARM Sensinode LWM2M client.

GREEN - Android sensor fusion app.

-----

2. Selecting RED for ARM Sensinode LWM2M client should output the following:

------

Attempting SSID Connection.

Connected - IP address: 192.168.1.52

[NSDL_DEBUG: /src/nsdl_run.cpp:144]ARM mbed NanoService Demo on Wi-Go for IoT World Hackathon

timeout set: 0

MAC address 00:37:6d:75:68:de

MAC: 00376D7568DEEP NAME: mbed-00376D7568DE

[NSDL_DEBUG: /src/nsdl_run.cpp:64]IP Address:192.168.1.52

[NSDL_DEBUG: /src/nsdl_run.cpp:80]name: mbed-00376D7568DE

[NSDL_DEBUG: /src/nsdl_run.cpp:81]NSP=192.168.1.220 - port 5683

libNsdl init done

[NSDL_DEBUG: /src/nsdl_run.cpp:92]Creating resources

TX callback!

Sending 271 bytes

NSP registering OK

Received 37 bytes

RX callback!

-----

3. Your Wi-Go is now connected to the ARM Sensinode platform and can be accessed through the RESTful web API. The MAC and IP addresses will of course be different. Please make note of the NAME, which starts with ‘mbed-’ followed by the 12 digit concatenated MAC ID. This is your unique endpoint ID in the system will be used to construct the HTTP path to your resources.

The ARM Sensinode platform instance being used for the hackathon has 3 ports open for http access:

http://192.168.1.220:8080/domain/endpoints

  • REST API resources representing endpoint data, see the technical reference page for more detail and instructions
  • User=’app2’
  • Password=’secret’

https://192.168.1.220:8081

  • Administration interface
  • User=’admin’
  • Password=’admin’

http://192.168.1.220:8083/

  • Demo application interface showing connected endpoints and displaying sensor resource values. You can look up your endpoint name and browse the resources on your Wi-Go board.
  • User=’demo’
  • Password=’demo’

coap:192.168.1.220:5683

  • M2M inerface; Wi-Go endpoints connect to the ARM Sensinode platform and transfer data using the IETF CoAP protocol over UDP

4. The resource schema for the Wi-Go sensors follows the OMA LWM2M object model, and uses existing IPSO object definitions where possible.

The base URL is:

To which is added the endpoint name, e.g.:

To which is finally added the resource path as per the following:

Battery Level (0-100 percent charge)

  • 3300/0/5700

Touch slider (0-100 percent on scale)

  • 3300/1/5700

Light Intensity (0-100 percent scale)

  • 3301/0/5700

Temperature (Degrees C)

  • 3303/0/5700

RGB LED 1=ON, 0=OFF

  • 3311/0/5850/0 (RED)
  • 3311/0/5850/1 (GREEN)
  • 3311/0/5850/2 (BLUE)

Accelerometer (G)

  • 3313/0/0 (X)
  • 3313/0/1 (Y)
  • 3313/0/2 (Z)

Magnetometer (UT)

  • 3314/0/0 (X)
  • 3314/0/1 (Y)
  • 3314/0/2 (G)
  • 3314/0/3 (Compass heading 0-359 degrees)

As an example, the light level for the above example board can be obtained by performing an http GET to the address:

5. Using the demo application at http://192.168.1.220:8083/ locate your WiGo board and click on the link in the Name column. A popup window should open with a tab for each resource type, e.g. 3300, 3301, etc. as well as a Device tab. You need to click on the ‘read’ buttons to refresh the values, which will refresh either from cached values or by reading the physical endpoint, depending on caching policy.

If all the resources appear in the demo app window, your Wi-Go board is connected to the ARM Sensinode platform and you can begin creating new connected device applications.

ARM mbed provides an embedded IDE to build the device-resident part of the application, and the ARM Sensinode platform provides an easy, standard, and interoperable way to connect your embedded device to web applications.

Here are some links for further information on the relevant standards and components in the system:

LWM2M Tutorial:

http://community.arm.com/docs/DOC-8693

CoAP Tutorial:

http://community.arm.com/docs/DOC-8633

General IoT Architecture and Standards:

http://community.arm.com/docs/DOC-8649

White papers and free downloadable developer version of ARM Sensinode platform:

http://community.arm.com/groups/smart-and-connected/blog/2014/05/07/white-papers-on-arm-iot-software


All wikipages