Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 14 Next »

IBM Watson IoT is IBM's IoT platform. This guide shows you how you can publish data to its Quickstart service, in minutes!

SmartMesh IP mesh networks and and IBM Watson IoT are perfectly complementary. Sending data gathered by a SmartMesh IP mote into the Watson IoT platform is a breeze, as you will see in this recipe.

Overview

Create your network

  • We assume you have a DC9000B SmartMesh IP starter kit

    There are many many things you can do with this kit, including connecting external sensors, reprogramming the motes, driving the motes from an external micro-controller, etc. In this recipe, we assume you are using an out-of-the-box kit, in which nodes are running the default firmware in master mode.

    In this mode, each mote publishes a temperature reading every 30s. This is what we will publish to Watson IoT Quickstart. 

  • Plug the manager into your computer's USB board and its blue LED switches on

    When you plug the manager into your computer, 4 serial ports appear on your computer. If you're using Windows, they are listed in your Device Manager.

    Note the number of the 4th port in the list, in my case "COM13".

  • Switch on at least one mote, two green LEDs are steady-on when the mote has successfully joined the network and is publishing data:

    The LEDs are only active when the blue "LED EN" jumper is placed, as in the picture above.

What just happened?

That's it, you have a fully functional SmartMesh IP network with every mote publishing a temperature reading every 30s.

Run the software

On your computer, you will need to run two programs: JsonServer and Node-RED

JsonServer

JsonServer is a program developed by the DustCloud community and part of the SmartMesh SDK.

It connects to your SmartMesh IP manager and opens an HTTP JSON interface that Node-RED can connect to.

  • Download the latest release of the SmartMesh SDK at https://github.com/dustcloud/smartmeshsdk/releases

    There are several ways of running the SmartMesh SDK, depending on your operating system. On my Windows computer, the quickest way is to download the pre-compiled binaries:

    Unzip the folder, and double-click on SmartMeshSDK-1.1.1.0-win\win\JsonServer.exe.

    You can of course also download the (Python) source code and run that. This is documented at SmartMesh SDK.

  • Run the application

Node-RED

Unable to render {include} The included page could not be found.

Publish to Watson IoT Quickstart

  • Copy the following Node-RED flow into Node-RED:


JSON version of the flow

[{"id":"85aa03bc.2a561","type":"http in","z":"c2baf2e0.c6144","name":"/oap","url":"/oap","method":"post","swaggerDoc":"","x":210,"y":329,"wires":[["b33dbfba.360c2","bed74bc9.84e9f8"]]},{"id":"b33dbfba.360c2","type":"http response","z":"c2baf2e0.c6144","name":"","x":339,"y":380,"wires":[]},{"id":"98a0ab7c.174b78","type":"debug","z":"c2baf2e0.c6144","name":"","active":true,"console":"false","complete":"false","x":568,"y":275,"wires":[]},{"id":"bed74bc9.84e9f8","type":"function","z":"c2baf2e0.c6144","name":"","func":"var motelabel = \"3FFEE6\" // <-- replace this\n\nvar re = /\\-/gi;\nif  (\n        msg.payload.mac.replace(re,'').endsWith(motelabel.toLowerCase()) &&\n        msg.payload.fields.channel_str==\"temperature\"\n    ) {\n    msg.payload = { d: { 'temperature': msg.payload.fields.samples[0]/100.0 }}\n    return msg;\n}","outputs":1,"noerr":0,"x":389,"y":329,"wires":[["98a0ab7c.174b78","50be9b24.6dd204"]]},{"id":"50be9b24.6dd204","type":"wiotp out","z":"c2baf2e0.c6144","authType":"d","qs":"true","qsDeviceId":"00-17-0d-00-00-38-06-d6","deviceKey":"","deviceType":"","deviceId":"","event":"event","format":"json","name":"","x":629,"y":331,"wires":[]},{"id":"950cedfd.0a177","type":"comment","z":"c2baf2e0.c6144","name":"step 1. configure JsonServer","info":"","x":195,"y":56,"wires":[]},{"id":"75bc8773.0f7818","type":"inject","z":"c2baf2e0.c6144","name":"connect serial port","topic":"","payload":"{ \"managers\": [\"COM13\"] }","payloadType":"json","repeat":"","crontab":"","once":false,"x":278,"y":117,"wires":[["a1074d41.2e556"]]},{"id":"a1074d41.2e556","type":"http request","z":"c2baf2e0.c6144","name":"","method":"PUT","ret":"txt","url":"http://127.0.0.1:8080/api/v1/config/managers","tls":"","x":491,"y":117,"wires":[["2135feb8.4493e2"]]},{"id":"2135feb8.4493e2","type":"debug","z":"c2baf2e0.c6144","name":"","active":true,"console":"false","complete":"statusCode","x":696,"y":120,"wires":[]},{"id":"1e720935.516127","type":"inject","z":"c2baf2e0.c6144","name":"get status","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":245,"y":170,"wires":[["783fd168.2187c"]]},{"id":"783fd168.2187c","type":"http request","z":"c2baf2e0.c6144","name":"","method":"GET","ret":"obj","url":"http://127.0.0.1:8080/api/v1/status","tls":"","x":488,"y":172,"wires":[["78ad7628.bb58f8"]]},{"id":"78ad7628.bb58f8","type":"debug","z":"c2baf2e0.c6144","name":"","active":true,"console":"false","complete":"payload.managers","x":731,"y":170,"wires":[]},{"id":"6085427f.629eec","type":"comment","z":"c2baf2e0.c6144","name":"step 2. send to Watson IoT Quickstart","info":"","x":219,"y":234,"wires":[]}]

To import the flow above in your Node-RED instance:

  • copy the string above (triple-click to select, then copy with Ctrl+C)
  • in your Node-RED editor, on the hamburger menu on the upper right, select "Import" > "Clipboard"
  • paste the string (Ctrl+V) and click "Import"
  • activate the flow by clicking on the "Deploy" button

  • Double-click on "connect serial port" and change "COM13" by the name of the serial port you noted above
     
  • Click the Deploy button on Node-RED
     
  • Click on the left of the "connect serial port" widget
  • Make sure the debug tab on the right contains "200"

    What just happened?

    You just issued a command to the JsonServer application to connect to your SmartMesh IP manager's serial port.

  • Click on the left of the "get status" widget
    Make sure the debug tab on the right contains "connected"

  •  

    What just happened?

    Your asked the JsonServer what its status is, and it responded that it is connected to your SmartMesh IP Manager.

  • Choose any one of your motes, and read its label, in my case "3FFEE6"

    What's that?

    The label contains the unique identifier of the mote.

  • In Node-RED, double-click on the function widget
     
  • Replace "3FFEE6" by what you have on your label and click Done
  • Double-click on the event widget
     
  • Change the Quickstart Id by your mote's identifier, and click Done
  • Click Deploy
  • Go to https://quickstart.internetofthings.ibmcloud.com
    • check the box to accept the terms and conditions
    • enter the identifier of your mote and press Go
  • You start by seeing an empty screen, this is normal as the mote only publishes every 30s
  • Every 30s, a new datapoint plots live

You can see the same data on different devices, just go to https://quickstart.internetofthings.ibmcloud.com and enter the identifier of your board.

Where next?

We hope to have convinced you of how easy it is to send data from your SmartMesh IP to IBM Watson IoT. We have obviously only scratched the surface of what's possible.

Things you can do with your SmartMesh IP motes

  • connect external sensors
  • connect external actuators
  • reprogram motes using the On-Chip SDK
  • etc.

Things you can do with IBM Watson IoT

  • create a your own Watson IoT instance (not the Quickstart) and send data in a quick and secure way into IBM Bluemix
  • start other IBM Bluemix services and applications to store, analyze and visualize your SmartMesh IP network and the data it produces
  • etc.
  • No labels