Register your KEPServerEX server with Watson IoT Platform and acquire device credentials
- Launch your Watson IoT Platform Service and navigate to the Devices page using the “DEVICES” tab.¬†¬†
- Click the “+ Add Device” button to add a new device.
- Click the “+ Add Type” button to add a new type.
- Give the type a name, for example “KEPServerEX” and then click “Add.”
- Give the device an ID, for example “MyKEPServerEX” and then click “Next.”
- Continue clicking “Next” a few more times until you reach the summary and then click “Done.”¬† IMPORTANT:¬† After clicking “Done” the next view will show the “Device Credentials.”¬† Make sure you copy these credentials and store them somewhere so that you can access them again.¬† Once you leave this view, you will not be able to get them back.¬†¬†
Configure the KEPServerEX IoT Gateway Plug-in
- Open KEPServerEX and select “Add Agent…” under the “IoT Gateway” in the left hand project browser.¬† Give the agent a name such as “IBM Cloud” and select “MQTT Client” in the type drop down list.¬† Then select “Next.”¬†¬†
- In the “MQTT Client – Broker” dialog, enter the URL, Topic and Timeout.¬† The URL should be in the format like the following:¬† ssl://<orgid>.messaging.internetofthings.ibmcloud.com:8883¬† ¬†The¬†<orgid> is your Organization ID from your Waton IoT Platform device credentials obtained in step one of this recipe.¬† The topic should be in the format:¬† iot-2/evt/<event name>/fmt/json¬† ¬†The¬†<event name> is the name of the event you want sent to Watson IoT Platform.¬† For example, “status.”¬† Lastly, put 60 for the timeout field and then click “Next.”¬†¬†
- In the MQTT “Client – Security” dialog, enter the Client ID, Username and Password.¬† The Client ID is in the following format:¬† d:<orgid>:<device Type>:<device ID>¬† ¬†You can get your¬†<orgid>, <device Type> and <device ID> from your device credntials obtained in step one of this recipe.¬† The username should be “use-token-auth” and your password should be your Authentication Token from your device credntials obtained in step one of this recipe.¬† Lastly, click “Finish” to complete the agent.¬† ¬†
- We need to change one more setting before the agent is complete.¬† Double-click on your new IoT Gateway agent in the project borwser.¬† Switch to the “Security” section and select “v1.2” as the TLS Version.¬† Then click “OK.”¬†¬†
If successful, you should eventually see something like the following in the KEPServerEX Event Log window:
“MQTT agent ‘IBM Cloud’ is connected to broker ‘ssl://u87tmj.messaging.internetofthings.ibmcloud.com:8883′”
Add some simulated tags to the IoT Gateway and view events in Watson IoT Platform
- Now we need to add some simulated tags to send from the KEPServerEX server to the IBM Watson IoT Platform.¬† With the new IoT Gateway agent selected in the KEPServerEX project browser, click on “Add IoT items…” in the right side pane.¬† This will bring up the “Tag Browser.”¬† In the Tag Browser left side navigation pane, select the “Functions” node under “Simulation Examples.”¬† This will bring up the tags in the right side pane.¬† Select tags “Ramp2” and “User3.”¬† Then click “Apply.”¬†¬†
- In the “IoT Items” dialog, leave the defaults and click “OK.”¬†¬†
- You should now see the two tags added to your IoT Gateway agent.¬†¬†
- Once the tags are added, the IoT Gateway agent will begin to send the simulated data to Watson IoT Platform every 10 seconds.¬† To view the incoming messages on IBM Cloud, Navigate to your Watson IoT Platform service “DEVICES” tab.¬† Your device should have a small green dot next to it to denote that it is connected.¬† If not, recheck the KEPServerEX event log to ensure there are no connection errors.
- Click on the device and switch to the “Recent Events” tab to view incoming messages.¬† You should see messages coming in about every 10 seconds.¬†¬†
- Lastly, you can click on the message itself to view the raw JSON payload.¬†¬†
In this recipe you learned how to connect a Kepware KEPServerEX to the IBM Watson IoT Platform using MQTT.¬† Now that the data is flowing to the IBM Cloud, there is a whole catalog of micorservices you can use to make use of that data.¬† Looking for an end-to-end IoT solution that will help you get jumpstarted in days?¬† Take a look at the IBM IoT Connection Service:¬†¬†https://www.ibm.com/support/knowledgecenter/en/SSQP8H/iot-connected-products/kc_welcome.htm.¬† This managed service offering from IBM provides the IoT Platform service as well as security, data lifecycle management and analytics.¬†
If you have any questions or issues with this recipe, please post comments below.