KEPServerEX is a connectivity platform that allows users to connect, manage, monitor and control diverse automation devices and software applications. KEPServerEX leverages OPC and IT-centric communication protocols (such as SNMP, ODBC, and web services) to provide users with a single source for industrial data.

PTC - Kepware have +20 years of experience helping businesses to connect diverse automation devices and software applications. They have been recognized as an early player in IIoT thanks to one of their products, the IoT Gateway, an advanced plug-in that extends the capabilities of the KEPServerEX connectivity platform which allows handling RESTful and MQTT requests for integration with web services in Manufacturing execution systems (MES) and other systems. This also seamlessly streams real-time industrial data directly into device clouds and Big Data analytics platforms across the whole company, which result to be useful in a handful of verticals including Manufacturing, Oil & Gas, Building Automation and Power & Utilities. To learn more visit the official documentation, or watch this video.

The objective of this guide is to explain how to setup the KEPServerEx's IoT gateway plug-in to stream data to an external MQTT broker. For the purposes of this demo, we’ll be using Node-RED as an intermediate broker to decode KEPServerEx’s payloads and encode them into an Ubidots-friendly format. While this makes it easier to understand what happens in the backstage, we don’t recommend this setup for applications in production as it involves an extra layer, prone to inefficiencies or failures

For applications in production, we recommend sending the data from KEPServerEx directly to a dedicated Ubidots MQTT broker, which can be setup under request by contacting support@ubidots.com

 

Requirements

Step-by-Step

  1. KEPServerEX Setup
  2. Ubidots Setup
  3. IoT Gateway Setup
  4. Node-RED integration (KEPServerEX + Ubidots)
  5. Data visualization in Ubidots
  6. Summary

1. KEPServerEX Setup

To get started with KEPServerEX follow the next steps for deployment and licensing.

IMPORTANT NOTE: Kepware offers free demo downloads, which is fully functional and only limited in its runtime to 2-hour periods. If further testing or POC is required, please contact the Sales department to extend your free trial period or get the license need it.

1. Download KEPServerEX. The software is available just for Windows OS.

2. From your Download folder, open the .exe file previously downloaded and proceed with the installation of the software. Please make sure to follow the installation process carefully to avoid any issue.

IMPORTANT NOTE: Kepware should be installed on the same local network as your automation equipment, this will help optimize data collection from your field devices, and help mitigate cybersecurity risks. 

3. With KEPServerEx already installed, open it and verify if the IoT Gateway plug-in is available. You can simply found it on the tree view at the left side of the software.

4. The software opens initially with a default project. Define a new project by choosing "File > New”. If prompted to close, select “Save”, or “Edit offline”.

5. To save the project created, choose “File > Save As…”. Enter the password configured in the installation process to secure the encrypted project file. Then, choose a location to store the file and click “Save” 

6. When creating a new project, users must first determine the communications driver required by the application: this is referred to as a channel in the server. A number of channels can be defined within a single project, depending on the driver or drivers installed.

For testing purposes we will be using the “Simulator Driver”, however in a real-world application we would select from one of the 150+ drivers provided by Kepware to pull data from our automation devices; such as the Allen-Bradly ControlLogix Ethernet Driver, ABB TotalFLow Driver, or the Modbus TCP/IP Drive.

Add a new channel to the project by following one of the options below:

  • Click "Edit > Connectivity > New Channel".
  • Select "Click to add new channel" from the project view or details view.
  • Right-clicking on the "Connectivity" node in the project view and choose "New channel".

7. Into the channel wizard, specify a name for the channel. In this example, we named it "Manufacturing Plant". With the name defined, press "Next":

8. In Device Driver, choose “Simulator” as the channel's type. Then, press "Next":

9. Leave the following configurations as default by clicking "Next" until finishing the channel creation. The last window should be the summary for the new channel (see below). Click “Finish” to close it:

10. With the channel defined, add a new device. The device identifies a communication link's physical node or station and can be thought of as a way to frame the connection's definition to a specific point of interest in the application.

Add a new device to the channel previously created by following one of the options below:

  • Click "Edit > Connectivity > New Device".
  • Select the channel, then  "Click to add a device" from the project view or details view.
  • Right-clicking on the channel created "Manufacturing Plant" in the project view and choose "New device".

11. In the device wizard, specify a name for the device. In this example, we called  it "Conveyor Belt". With the name defined, click "Next":

12. In Model, select “16-bit” register size for the device being simulated and click “Next”.

13. Leave the following configurations as default by clicking "Next" until finish the device creation. The last window you should have is the summary for the new device (see below). Click “Finish” to close it:

14. With the device created, it’s time to create the tags. Tags represent addresses within the PLCs or other hardware devices that the server communicates with. Tags can be defined as a single tag or tag groups.

Add a new single tag in the device previously created by right-clicking on the device and choosing "New Tag":

In the tag properties, edit the properties to match the following:

  • Tag Name: Sensor 1
  • Description (optional): Simulated values from -20 to 75 every 100 ms 
  • Address: RANDOM (Rate, Low Limit, High Limit) - RANDOM (100, -20, 75)
  • Data Type: Default
  • Client Access: Read only
  • Scan Rate (ms): 100

Having has result:

NOTE: The configuration above can be customized as you desire. Keep in mind this is just a tag that simulates random values. 

15. [Optional] To simulate more values in the “Conveyor Belt” device, repeat the last step as many times as desired. If you create more that one tag you should have the following result:

To simulate a second device, repeat the steps above. 

2. Ubidots Setup

If you’re not familiar with Ubidots IoT development tools yet, you may refer to the following guides:

1. In case you already don't own an Ubidots account, create one here

2. To be able to integrate the data incoming from KEPServerEx with Ubidots you'll need a key from your account. This key is identified as TOKEN and can be easily found in the "API credential" option from the user dropdown. 

A TOKEN is an authentication key to interact with Ubidots’ API. Keep in mind the TOKEN provided in the user dropdown has access to all devices in your Ubidots account. For security purposes, we highly recommend using Organizational TOKENS, which allows you to create TOKENS to interact with resources within a single organization. Refer to the following guide to learn more:

NOTE: We’ll need this TOKEN in Step 4: Node-RED integration.

3. IoT Gateway Setup

1. Refer to the "IoT Gateway" from the project configurations and press "Add Agent":

2. In the new agent dialog, enter “Ubidots MQTT client” as name for the agent and choose “MQTT client” as type. To continue, press “Next”:

3. Within the MQTT Broker configuration, assign "ubidots" as topic and leave other configuration by default. To continue, press “Next”:

4. For now, leave the credentials in blank and proceed with the creation by pressing "Finish". Once the agent is created, you should be able to visualize it within the IoT Gateway tree:

NOTE: Agent settings can be updated after configuration by double-clicking the agent name. 

5. To start running the broker just configured, we're going to use Mosquitto, an open-source message broker that implements the MQTT protocol. In case you don't have installed it, refer to the download page

To run the broker, open the command prompt and insert the following command:

"c:\Program Files\mosquitto\mosquitto.exe"

At this point, you'll be able to see how mosquitto is running in the window border of the command prompt:

6. Right-click the agent previously created  and select “New IoT Items”:

7. Within the tag browser, refer to the channel “Manufacturing Plant” and select the device “Conveyor Belt”. Then, select the tags desired to publish in this agent. As you can see below, we are adding the tags "Sensor 1", "Sensor 2", and "Sensor 3". Once the tags are selected, click Apply.

8. In the IoT Items dialog, leave the configurations as default. To continue, press “OK”:

9. At this point, you may see the items added in the details view.

10. [Optional] In case you included more than one device into channel configuration, feel free you include them as items in the agent created. Having the following result in the details view:

4. Node-RED integration (KEPServerEX + Ubidots)

1. Open the Command Prompt, and run the following command to initialize Node-RED. In case you don't have Node-RED installed in your computer refer to this guide.

Commnad to run: node-red 

Wait a couple of seconds until Node-RED start running the server.

2. Once the server started running properly, access it in the web browser of your preference by using the address and port defined in the command prompt,  which should be “127.0.0.1:1880”.

3. Next, click on the Node-RED menu in the upper right corner, then “Import > Clipboard” and paste the code below. 

[{"id":"149030d9.1c91df","type":"debug","z":"19f25fb7.4d4f6","name":"Incoming JSON","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":620,"y":460,"wires":[]},{"id":"a20b66ac.e80948","type":"json","z":"19f25fb7.4d4f6","name":"","property":"payload","action":"","pretty":false,"x":390,"y":520,"wires":[["149030d9.1c91df","c8823efc.69e59"]]},{"id":"c8823efc.69e59","type":"function","z":"19f25fb7.4d4f6","name":"Parse incoming data","func":"var response = {};\nvar obj = {};\nvar devicePosition = 2;\nvar variablePosition = 1;\n\nfor (var i in msg.payload.values) {\n    // Grab channel ID of the tag which is sending the message\n    var id = msg.payload.values[i].id;\n    // Replaces the blank spaces found in the channel ID with a dash\n    id = id.replace(/ /g, \"-\"); \n    // Splits the ID to extract the labels for the devices & variables. \n    var parseID = id.split(\".\");\n    var size = parseID.length;\n    // Grab Device label from channel ID\n    var device = obj[parseID[size - 2]] || {};\n    // Grab Variable label from channel ID\n    var variable = device[parseID[size - 1]] || [];\n    // Build the payload to be sent according to the Ubidots API.\n    // Official documentation: https://ubidots.com/docs/sw/\n    variable.push({\"value\": msg.payload.values[i].v, \"timestamp\":msg.payload.values[i].t});\n    // Saves the payload built\n    device[parseID[size - 1]] = variable;\n    obj[parseID[size - 2]] = device;    \n}\n\n// Returns an Array with the parameters keys saved into the object \"obj\"\nvar devices = Object.keys(obj);\n\nfor (var j in devices) {\n    // If your KEPServerX configuration uses Tag Groups, please use the topic commented\n    //response.topic = \"/v1.6/devices/\" + parseID[size - 3] + \"-\" + devices[j];\n    response.topic = \"/v1.6/devices/\" + devices[j];\n    // Saves the payload to be sent\n    response.payload = obj[devices[j]];\n    // Sends payload to Ubidots MQTT Broker\n    node.send(response);\n}","outputs":1,"noerr":0,"x":640,"y":520,"wires":[["e21dc874.0b75a8"]]},{"id":"8201ac6.4acfa5","type":"debug","z":"19f25fb7.4d4f6","name":"Data to be sent to Ubidots","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1230,"y":460,"wires":[]},{"id":"17fd99af.a7bde6","type":"mqtt out","z":"19f25fb7.4d4f6","name":"Ubidots MQTT Broker","topic":"","qos":"1","retain":"","broker":"de02fa04.20ef28","x":1220,"y":520,"wires":[]},{"id":"cc16f5a7.cadb48","type":"mqtt in","z":"19f25fb7.4d4f6","name":"MQTT Client - KEPServerEX","topic":"ubidots","qos":"1","datatype":"auto","broker":"4691895c.0fb8f8","x":140,"y":520,"wires":[["a20b66ac.e80948"]]},{"id":"e21dc874.0b75a8","type":"throttle","z":"19f25fb7.4d4f6","name":"5 sg throttling","throttleType":"time","timeLimit":"5","timeLimitType":"seconds","countLimit":0,"blockSize":0,"locked":false,"x":940,"y":520,"wires":[["17fd99af.a7bde6","8201ac6.4acfa5"]]},{"id":"de02fa04.20ef28","type":"mqtt-broker","z":"","name":"Ubidots MQTT Broker","broker":"industrial.api.ubidots.com","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"4691895c.0fb8f8","type":"mqtt-broker","z":"","name":"MQTT Client- KEPServerEX","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

4. Enter the “Ubidots MQTT Broker” node, and click on the edit icon. In the security tab assign your Ubidots TOKEN as username.: 

5. Once the Ubidots TOKEN is assigned, click on “Deploy”.

At this point, the status of both MQTT nodes should appear as connected. Also, if you wish to visualize the logs of the payloads, you may click on  the debug tab.

5. Data visualization in Ubidots

1. Go to the device section of your Ubidots account; you should see new devices automatically created:

2. Enter the device “Conveyor Belt” and see the tags configured transmitting the simulated data:

3. To present devices' data and insights derived from the data we suggest exploring Ubidots Dashboard, where you’ll be able to create widgets to display the data as charts, indicators, controls, tables, graphs, and more.

To create your first dashboard, go to the Dashboard tab (Data →  Dashboards). Then, select the plus (+) icon in the top-right , then select the desired widget type. You should be able to create dashboards like the one below: 

6. Summary

KEPServerEX is more than just an OPC server; it's a platform for industrial automation and IoT. On the other hand, thanks to the features offered by Ubidots, you'll be able to model any sensor, robot, PLC, or a production line in a friendly and intuitive web environment.

In just a few minutes you've integrated KEPServerEX IoT Gateway with Ubidots, sent some sample data using the simulator driver, and reported your work to Ubidots for data retention, visualization, and transformation. You’re now ready to launch industrial applications in a matter of days instead of months.

Other readers have also found useful…

Did this answer your question?