Article

Tuto : Connectez votre Passerelle LoRa et Mdots MultiTech à la plate-forme IBM Watson IoT
  • DataPrint
  • blog
  • Tuto : Connectez votre Passerelle LoRa et Mdots MultiTech à la plate-forme IBM Watson IoT
Tuto : Connectez votre Passerelle LoRa et Mdots MultiTech à la plate-forme IBM Watson IoT
Par Romain Doussau dans blog Publié 6 octobre 2016 0 Commentaire

Overview

Skill Level: Any Skill Level

Guided step by step to set up your LoRa network, internet connectivity to the Conduit and start sending Gateway/Device Events messages and receiving Gateway/Device commands to/from Watson IoT platform. PS: In my next edit i will add pictures

Ingredients

  • Bluemix account
  • Bluemix application created with the Internet of Things Platform Starter boiler plate.
  • Multitech Multiconnect Conduit v1.2.2 AEP + LoRa mcard
  • Multitech Multiconnect mDot Developer Kit LoRa
  • Serial to Usb cable + driver
  • Ethernet cable
  • Router with internet access
  • Any hyperterminal such as Tera Term ,YAT …

Step-by-step

  1. Getting started with the Conduit

    Please watch the following video before starting the tutorial :

    ,if you want to follow this step by step i recommend to reset the conduit to factory settings

    • Take your Conduit, plug the power cord and plug the ethernet cable to the Conduit and on your computer to have a direct network connection.
    • By default the conduit has an hardcoded ip adresse : 192.168.2.1 , wait 2 minutes for the conduit to start and open your web browser and browse the ip 192.168.2.1

    If you can”t browse it, on your pc check the ethernet network setting and make sure that you are on the same subnet (you can type manually the ip address for example 192.168.2.4 rather than using DHCP)

    • Log in to the conduit using the default factory credential : user : admin password : admin
  2. Set up Conduit internet connectivity using the ethernet port

    The goal here is to replace the direct ehternet connection to the Conduit by plugging it to a router with internet access, this will allow us to send data from the Conduit to the watson IoT platform.

    • From the home screen click on the Setup button on the left hand side then on Network Interfaces
    • On the eth0 network interface click on the pen on the right hand side to change options.
    • Keep the type to LAN, set the mode to Static, for the gateway and Primary DNS server set the ip address of your router, in my case it”s 192.168.1.254 for both.
    • For the Ip address of the conduit i defined 192.168.1.80 but it could be anything like 192.168.1.x as long as x is not attributed to some other device.
    • Define the Mask to 255.255.255.0 and click on the finish button.
    • Now click on Save and Restart button from the left hand side menu.
    • While the Conduit is restarting, unplug the ethernet from your pc and plug it now to the router.
    • Wait 2 minutes and browse the ip address you defined, in my case 192.168.1.80 and log in with admin/admin
  3. Enable and set up the LoRa network on the Conduit

    In this step we will enable the LoRa network of the mCard installed on your Conduit, define a Network name and passphrase for the mDot to join the network.

    • From the Conduit web interface click on Setup and LoRa Network server.
    • Tick the box Enabled, Network Id to Name, define the name as you like (in my case conduit1) , Network key  toPassphrase and define the passphrase as you like (in my case conduit1)
    • Click on Submit at the bottom then click on the Save and restart left hand side menu
    • Wait 2 minutes for the conduit to restart and log back in to it
  4. Enable and set up the mDot to join the Conduit LoRa network

    We are going to connect the mDot to our pc using Serial to USB connector and with an Hyper terminal we are going to send AT command to the mDot to jon the Conduit LoRa network.

    • Plug your Serial to usb cable on the serial port of the mDot Developer board and the usb to your pc.

    You might need to install driver of your Serial to USB cable, in my case i have got this old one :http://www.prolific.com.tw/US/ShowProduct.aspx?p_id=229&pcid=41

    • Now on your hyperterminal set up your com port for your serial connection to the mDot, Baud rate to 115200, Data to 8 bit, Parity to none, Stop to 1 bit, Flow control to none and no delay
    • Initiate the Serial connection to the mDot and on your terminal then type at, you should recieve a OK response.
    • Start by resetting the mDot to factory default settings with at&f command
    • Now let”s set the Network name with at+ni=1,conduit1 in my case and you should get a OK response
    • Same for passpharse with at+nk=1,conduit1 in my case and you should get a OK response

    What we”ve just set up are the mandatory primary fileds that need to match during network authentification between mDot and the Conduit in Europe for the moment (In the USA you”ll have also to match the Frequency Band and Frequency Sub band)

    • Go back to the Conduit web app and select Status & Logs on the left hand side menu, click on Statistics then select the Lora tab and at the bottom of the windows you should see the mDot that joined the network.
    • Keep the Serial connection open and don”t close your Hyper Terminal window, we will need it for next steps
  5. Create a Node-Red flow on the Conduit to exchange messages with the mDot

    In this step we will demonstrate how we can exchange messages between Conduit and mDot in both ways using Node-Red and AT commands.

    • On the Conduit web app click now on Apps then select Node-Red
    • Log in using admin/admin, from the left hand side menu, in the input categorie drag and drop LoRa input nodeto the canvas.
    • Now drag and drop a Debug node from the output on to the canvas, connect the LoRa node to the Debug, on right hand side click on the debug tab (to see data flowing from mDot to the conduit) and click on the Deploybutton (Red button top right of the canvas).
    • Now come back to your hyper terminal and write the AT command to send a message, at+send=hello world(what is after the = is the payload of your message) when you hit enter come back to Node-Red and you should see the the data sent to the Conduit on the Debug tab.

    As LoRa network is made for low energy consumption, the quality of services of messages ar not as effective as in mqtt for exmaple, you might not recieve the message sent from the mDot to the Conduit instantly

    • On Node-Red drag and drop a LoRa ouput node to the canvas and connect it to LoRa input node.
    • Come back to the terminal window and type the command to listen to any recieved messages, at+rxo=1
    • Now send the following at command at+send=12345678 , you should see the message “12345678” on your terminal window (meaning that the message has been recieve on the mDot) and on Node-Red

    This simple example demonstrated how messages are exchanged between Conduit and mDot in both ways, let”s now send message from mDots and Conduit to the Watson IoT platform.

  6. Register your Conduit Gateway and mDot devices to the IBM Watson IoT platform

    Assuming that you already created your IoT application on Bluemix using the Internet of Things Platform Start boiler plate (recipe pre-requisite), we will now register our gateway using the Watson IoT platform user interface.

    • On your Bluemix dashboard click on your IoT application
    • Click on the IoT platform service and Launch the dashboard
    • Clik on Device then click on the button +Add Device
    • Now create a device Type then Create a gateway type
    • Enter the name you like, in my case conduit_lora and description is optional
    • Click Next those values are optional i chose not to set them up for the moment, click Next and Next again
    • Click on create, now make sure that the gateway device type you created is selected in the combo box and click Next
    • Enter a device id of your choice, conduit1 in my case and click Next and Next again
    • Now up to you if you want to chosse your authentification token or if you want it to be generated randomly, i”ve chosen to click on Next and get the token generated for me.
    • In the case you randomly generated your token, copy and paste it somewhere on a text file for later and you can close by clicking on the cross
    • Now our gateway is registred on Watson IoT platform, the mDot will be automatically authentificated when the Conduit will send messages on his behalf using an approriate mqtt topic
  7. Create a bridge between the Conduit and the Waston IoT platform

    First we are going to settup a bridge from the conduit the Watson IoT, then you will do on your own the same but the other way around from the Watson IoT to the Conduit and to the mDots

    • Come back to Node-Red on your conduit, drag and drop a mqtt output and a json node from the left hand side menu to the canvas
    • Disconnect the LoRa output node from the LoRa input node and connect the LoRa input node to the json node and connect the json node to the mqtt output node
    • Double click on the mqtt output node to access properties of the mqtt client
    • Let”s start with the broker set up, click on the combo box and select Add new mqtt-broker and click on the pennext to it
    • Broker host is your orgid concatenated with .messaging.internetofthings.ibmcloud.com and the port is 1883, in my case it”s 3ru070.messaging.internetofthings.ibmcloud.com
    • Client id is g:org_id:device_type:device_id in my case g:3ru070:conduit_lora:conduit1
    • Username is use-token-auth and the password is the Token generated for your Conduit when you registered it to Watson IoT in the previous step and click OK
    • Now let”s fill in the topic, here we want the Conduit to send messages on the behalf of the mDot, to do so we need to contruct a topic as follow : iot-2/type/device_type/id/device_id/evt/event_id/fmt/formatstring in my case i chose to define arbitrary the device id of my mDot to 12345678 so my topic looks like this : iot-2/type/mdot/id/12345678/evt/event/fmt/json (you could dynamically build your topic based on the previous message using a function node)

    have a look at the Gateway documentation for more information :https://docs.internetofthings.ibmcloud.com/gateways/mqtt.html

    • Now go to the Node-Red of your Bluemix IoT app by clicking on the route of your app :app_name.mybluemix.net
    • Drag and drop an ibmiot input node to the canvas and double click on it to set up its properties.
    • Authentification : Bluemix Service, input Type : Device Event, Device Id let”s tick the box for all, Event tick the box for all, Format : json, Name it mDot LoRa and click OK
    • Drag and drop a debug node and connect it to the IbmIoT input node
    • Come back to your hyper terminal and write a AT send command, at+send={ “State”: 1, “Temp”: 27 } and press enter
    • You should see the message on the debug tab of the conduit Node-Red as well as on the Bluemix Node-Red and that validate that we can now send event message from the mDot to the Waston IoT platform

    Using the same principe and concept you will be able to send event/commands from the Watson IoT platform to the Conduit/mDot

Source : www.developer.ibm.com