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 was established in 1995 and has spent the last 20+ years building a portfolio of industrial connectivity solutions to help businesses connect diverse automation devices and software applications. Recognized as an early player in the Industrial Internet of Things (IoT), and serve a wide range of customers in a variety of vertical markets—including Manufacturing, Oil & Gas, Building Automation, Power & Utilities, and more.

The IoT Gateway, an advanced plug-in that extends the capabilities of the KEPServerEX connectivity platform, 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 refer to the official documentation, or watch this video.

This guide purpose is explaining how to setup KEPServerEx's IoT gateway plug-in to send data to Ubidots through its REST HTTP Client.

Requirements

Step-by-Step

  1. UbiFunctions Setup
  2. KEPServerEX Setup 
  3. IoT Gateway Setup (Ubidots + KEPServerEX) 
  4. Data visualization in Ubidots
  5. Summary

1. UbiFunctions Setup

If you’re not familiar with Ubidots IoT development tools yet, please create an account here and refer to the following guides to learn the basic features:

After creating your account, the next step is integrate the data coming from KEPServerEx with Ubidots. To do so, you'll need the UbiFunctions feature, which allows to transforming the data. 

  1. To create a Function go to your Ubidots account > Devices > Functions.

NOTE:  Ubifunctions is included in Professional plans and above.

2. Click the blue plus icon in the upper-right corner to create a Function:

3. Assign a name to the Function, choose POST as the HTTP method from the scrollbar and select the NodeJS 10 as runtime.

4. Now,  just copy and paste the code below into the UbiFunctions editor. When pasted, assign your Ubidots TOKEN where indicated:

var request = require('request-promise');

var token = "PUT_YOUR_TOKEN_HERE";

// Main function - runs every time the function is executed.

// "args" is a dictionary containing both the URL params and the HTTP body (for POST requests).

async function main(args) {

  var msg = args.values;
  var value1 = msg[0].v;
  var value2 = msg[1].v;

  var payload =  {"temperature": value1, "humidity": value2};

  var response = await ubidots_request(token, "chocolate-production", payload);

  return response ;
}

// This function builds an HTTP POST request to Ubidots

async function ubidots_request(token, label, body) {

  var options = {

    method: 'POST',
    url: 'https://industrial.api.ubidots.com/api/v1.6/devices/' + label,
    body: body,
    json: true,
    headers: {
      'Content-Type': 'application/json',
      'X-Auth-Token': token
    }
  };
  return await request.post(options);
}

IMPORTANT NOTE: The TOKEN is a unique key that can be easily found in the "API credential" option from the user drop-down. 

5. Finally, save the Function by clicking in "Make it live" button. 

2. 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 for licensing inquiries.

1. Download KEPServerEX. (Note: The software is available just for Windows OS.)

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

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 mitigate cybersecurity risks. 

3. With KEPServerEx already installed, open the program and verify if the IoT Gateway plug-in is available. You can find it on the tree view in 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 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 it's a way to frame the connection's definition to specific points of interest in the application.

Add a new device to the previously created channel  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 previously created device by right-clicking on the device and choosing "New Tag":

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

  • Tag Name: Humidity 
  • Description (optional): Humidity of Chocolate 
  • 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 desired. Keep in mind this is just a tag that simulates random values. 

15. To simulate more values in the Engine 1 or Engine 2 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 an additional device, repeat the steps above. 

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 “HTTP Ubidots Gateway” as name for the agent and choose “REST Client” as type. To continue, press “Next”:

3. Within the REST Client configuration, assign the UbiFunctions URL and select "POST" as Method. Leave other configuration by default and continue by pressing “Next”:

4. In the Header section, just add "Content-type: application/json" and Finish the creation.

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

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

7. Within the tag browser, refer to the channel “White chocolate production” and select the device “Engine 2”. Then, select the tags desired to publish in this agent. As you can see below, we added the tags "Temperature" and "Humidity". 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 all items added in the details view.

4. Data visualization in Ubidots

Go to the "Devices" section of your Ubidots account; you should see new devices automatically created:

2. Enter the device "Chocolate production” and see the tags configured transmitting the simulated data:

3. To present devices' data and insights derived from the data we suggest exploring the Ubidots Dashboards module, 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 and select the desired widget type. You should be able to create customized dashboards like the one below: 

5. 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?