KEPServerEX IoT Gateway configuration for Microsoft Azure's IoT Hub
Initial Setup and Configuration
Introduction
This document is intended to server as a basic guide on configuring the KEPServerEX IoT Gateway to publish automation data from the server to an Azure IoT Hub via MQTT.
This guide assumes a certain degree of familiarity with both the KEPServerEX, and Azure’s IoT Hub and does not serve as a substitute for any in-depth manuals – the help files for both products should be references for any topics for which further information is needed.
Requirements and System Setup
This document requires that a certain amount of setup be done outside of the KEPServerEX in order to facilitate the connection setup, and access to an instance of Microsoft Azure is mandatory. A third party tool – developed by Microsoft – is also required:
https://github.com/Azure/azure-iot-sdk-csharp/tree/master/tools/DeviceExplorer
The Device explorer generates the security tokens that the KEPServerEX IoT Gateway will use when connecting to the IoT Hub.
In order for the IoT Gateway to work, the computer on which the KEPServerEX is installed on must have a working 32-bit Java JRE or full JDK installed (version 7 or higher). Ideally the machine will be running the latest JRE/JDK from Oracle, which can be downloaded below:
Configuring the Azure IoT Hub
- Log into the Azure instance, and open the IoT Hub
- Navigate to Shared access policies ⇒ <Policy or key name to be used> and make a copy of the Connection string – primary key field highlighted below
- Open the Device Explorer, and on the Configuration tab provide the Connection string that was just copied from Azure, as well as the host name. The host name will take the form of:
<Your-IoT-Hub-name>.azure-devices.net
Press the Update button when complete - On the Management Tab of the Device Explorer:
- Hit the List/Refresh button to enumerate a list of devices currently configured in the IoT Hub. If no devices are configured yet the Create button can be used to create a new device in the hub.
- Press the SAS Token… button and select the Device from the Drop Down.
- Use the Generate button to generate a SAS Token
- Copy the SAS Token starting with the highlighted section below, and including the obfuscated piece in black.
Configuring the IoT Gateway
- Add a New Agent to the IoT Gateway section of the KEPServerEX – the Type should be set to MQTT Client, but the Name is user configurable.
- The MQTT Broker setting should be set:
- URL:
ssl://<host-name>:8883 - Topic:
devices/<device-name>/messages/events/<topic-name>
- URL:
- The Azure Security/Authentication settings must be set:
- Client ID:
<Device ID of device in IoT Hub that IoT Gateway is publishing to> - Username:
<host-name>/<device-name> - Password:
<SAS token copied from Device Explorer>
- Client ID:
- Press Finish to create the Gateway – it should start automatically. Add any tags from the Project that should be published to the Gateway configuration.
Conclusion
The IoT Gateway will now publish all tags that have been added to the Gateway configuration at the publish rate specified. Refreshing the message count in the IoT Gateway will show that the data is being pushed to the specified device.