Sunday, May 29, 2016

Wio Link and Node-RED

Here is a jewel for the enthusiasts of IOT: the Wio Link board. When used along with Node-RED we have a powerful IOT module that is easy to prototype and test.






This board was created by a talented young team from Seeedstudio. My respects to those brigth minds. They managed to create a product that is really , really and I mean really plug and play. This board overcomes the few hurdles of ESP8266 module.

The solution bundles many smart and handy features: (1) easy to add and change sensors and actuators by using the family of "plugable" Grove modules (2) quality circuit board with integrated USB and power regulator (3) download of configuration files via WIFI , also known as OTA - Over the Air configuration (4) Android and IOS apps to allow visual configuration of the modules (5) APIs exposed in a public server to allow Restful HTTP access to the data from sensors (6) fair prices (for the overall quality of the product) (7) configurations open sourced(8) Seeedstudio encourages the communitity of IOT enthusiasts and has opened a space in their web pages to allow people to show off ideas and projects thru "recipes". (9) Support for integrating Wio Link to IFTTT environment (something good for starters but contrained by the slowness of  IFTTT servers).


The operation of the board is performed by this sequence of three (easy) steps:

(1) Visual Programming (drag and drop) the Wio Link card

(2) Download configuration to Wio Link via WIFI (over the air)

(3) Command (read / write) your sensors via internet

Those three steps require connection to the internet. None of them can be done without internet access.

First things first....

Before you can start using your Wio Link and Grove modules there is a initial setup to be carried out. The purpose of this initial setup is to create a login in a public server and tell  Wio Link board what is the wireless network it has to connect as a client to have internet access. 

Guess how this initial setup will be done ?  Whoever designed this setup process certainly decided it should be simple and not rely on physical connection to Wio Link. How Wio Link could possibly know which wireless network to use , among many that are normally available,  and how to give Wio Link the SSID and password ?

Here comes the app. The whole idea is to allow the smartphone to connect to the Wio Link to sent the SSID and password of the wireless to be used.

The process is ilustrated on this page of Seeedstudio: click here

Seeedstudio also produced a short video, available in their site as well as in YouTube, that shows how to make the initial setup.


First the app will help you to sign up to the exchange server and register your node. Once this account is create you will be granted two different tokens that will be needed whenever you need to collect data from the sensors or command the actuators.



The second step in the process is to press the configuration buttom in the board for a period of 4 seconds. This will turn on the WIFI access point in the ESP8266 module. You will notice immediatelly that a new (and temporary) WIFI network will show up as available. The only purpose of this WIFI access point is to communincate a couple of information to your Wio Link (from your smartphone).



You then press the "GOT READY" buttom in the app and you will be asked to select what is the access point that should be used by Wio Link from now on. You will provide to the app the network SSID and the password. The app will forward this information to Wio Link over the temporary WIFI access point. When done Wio link will switch from access point mode (temporary wifi) to client mode of your wireless network.

Now the Wio Link uses the same network as your smartphone and both are able to reach the exchange server.



You have seen how the app helped to generate the intial setup for the board.

Now let me show you what the drag and drop visual interface of the app generates. The whole purpose is to come up with a JSON file that will guide the server on how to download the drivers to the Wio Link. The name of the file generate is : connection_config.json

This file has only two lines: the first one indicating the model of the board, in our case: "Wio Link V1.0" and the second one being a list of the Grove modules that we visualy connected to Wio Link, in below example: two modules (sku) attached to the ports UART0 and I2C.

{
"board_name": "Wio Link v1.0", 
"connections": [
    {"sku": "111020001", "port": "UART0"}, 
    {"sku": "101020050", "port": "I2C0"}
]
}


You can´t do any kind of programming logic on the app. Also the app has not a dashboard to present data in a more friendly and useful way. On the other hand the app can send pre loaded HTTP requests to the server to read and write values to the Grove modules. However this feature is too simplistic.

Here is where Node-RED comes into play. It can communicate with Grove sensors via HTTP, execute any logic you can think of and interface with your preferred dashboard to display data in a meaningful way.

This is what we will start doing in the next post...

See you then.