Email Us at [email protected]

Download N3uron

RESOURCES / ARTICLES

How to Connect your Industrial Assets to Microsoft Azure IoT Hub using N3uron’s MQTT Module

Azure IoT and N3uron logos with Solar plant view underneath.

Connecting Azure IoT Hub: Overview

As stated in our previous article, MQTT: The Universal Messaging Protocol for Cloud Providers and IIoT Systems, MQTT has emerged as the defacto standard for IIoT and of course, is also supported by Microsoft Azure.

OT infrastructures can be connected to Azure IoT Hub using MQTT, enabling access to the entire ecosystem of services currently provided by Microsoft Azure and for instance, making it very easy to ingest real-time data in Stream Analytics and subsequently perform actions or send alarms using Event Hubs or Azure Functions. In short, Azure IoT Hub is the service that receives and routes MQTT messages from edge devices and applications such as N3uron.

This guide explains in detail how to communicate your industrial assets bi-directionally with Azure IoT Hub in a secure way through N3uron’s MQTT module and thus, bridge the gap between OT and IT.

Diagram showing operational data flow between Azure IoT Hub and N3uron IIoT platform

Diagram showing operational data flow between Azure IoT Hub and N3uron IIoT platform.

Azure IoT Hub and N3uron Requirements

It is assumed that you already have an Azure subscription. If not, you can create one at https://azure.microsoft.com/en-us/free/search/.

If you haven’t downloaded N3uron yet, you can do so at https://n3uron.com/downloads/. If this is the first time you are installing N3uron, our Quick User Guide will guide you through the entire installation process.

You will also need access to Azure IoT Explorer, a graphical tool for interacting with all devices connected to your IoT hub. Go to Azure IoT explorer releases and expand the list of assets to see the most recent release. Download and install the most recent version of the application.

Setting up an Azure IoT Hub

Creating a new IoT Hub

  • Step 01: Log into Microsoft Azure and go to the Azure Portal. Click on the link to get to the Microsoft Azure Portal.
Image displaying Azure IoT Hub portal tools panel

Screenshot displaying Azure portal tools panel.

Once logged in, you’ll need to create the Azure resources that your device, in our case a N3uron node, will require in order to connect to the Azure IoT Hub and start exchanging messages.

  • Step 02: From the Azure homepage, select the + Create a resource option and then enter IoT Hub in the Search the Marketplace field.
  • Step 03: Select IoT Hub from the search results and then select Create.
Picture showing how to create a hub in Azure IoT Hub

Screenshot displaying how to create a hub within the Azure IoT Hub.

  • Step 04: In the Basics tab, complete the fields as follows:
    – Subscription: Select the subscription to use for your hub. In this example, we have selected Azure subscription 1.
    Resource Group: Select a resource group or create a new one. To create a new one, select Create new and fill in the name you want to use. To use an existing resource group, select the specific resource group. For more information, see Manage Azure Resource Manager resource groups. In this example, we have selected CS_N3uron.
    Region: Select the region you want your hub to be located in. Select the location closest to you.
    IoT Hub Name: Enter a name for your hub. In this example, we have named it N3-IoT.
Image displaying Azure IoT Hub project details panel

Screenshot displaying Azure IoT Hub details panel.

  • Step 05: Select Next: Networking to continue creating your hub. Choose the endpoints that the devices can use to connect to your IoT Hub and select the Public access default setting.
Picture Showing Azure IoT Hub networking panel

Screenshot displaying Azure IoT Hub networking panel.

  • Step 06: Select Next: Management to continue creating your hub Accept the default settings here.
  • Step 07: Select Next: Tags to continue to the next screen. Accept the default settings here.
  • Step 08: Select Next: Review + create to review your choices. You should see something similar to this screen but with the values you selected when creating the hub.
  • Step 09: Select Create to start the deployment of your new hub. Your deployment will remain in progress for a few minutes while the hub is being created. Once the deployment is complete, select Go to resource to open the new hub.
Image showing validation passed confirmation in Azure IoT Hub platform

Screenshot displaying validation passed confirmation in Azure IoT Hub.

Configuring Your Shared Access Policy

You can choose between two different mechanisms provided by Azure IoT Hub to authenticate devices and services: Security Tokens and X.509 Certificates. In this example, we are going to use Security Tokens. These Security Tokens are also known as Shared Access Signature (SAS) tokens. For more details about configuration using X.509 Certificates, please visit our Knowledge Base.

  • Step 01: In the resource panel of the IoT Hub you have just created, select Shared access policies.
  • Step 02: Click on iothubowner and copy the Primary connection string from the right-hand panel.
Picture Showing shared access policies panel in Azure IoT Hub platform

Screenshot displaying the shared access policies panel in Azure IoT Hub.

  • Step 03: Start the Azure IoT Explorer, click on the + Add connection button, and paste the Primary connection string in the Connection String text box. Next click Save.
Image displaying Azure IoT Explorer Graphical Tool interface

Screenshot displaying Azure IoT Explorer Graphical Tool interface.

  • Step 04: In the Devices section, click on the +New button and enter a name for your device. In this example, we have named it “N3uron_Gateway”. In Authentication type, select Symmetric key, check the Auto-generate keys field, and click on Create.
Picture Showing the create a new identity window in Azure IoT Explorer interface

Screenshot displaying the create a new identity window in Azure IoT Explorer interface.

  • Step 05: After creating the new identity, expand the Connection string with SAS token section. In the Symmetric key drop-down menu, select Primary Key, enter a sufficiently high figure in Expiration (minutes), click on the Generate Button, and copy the part of the SAS token connection string form SharedAccessSignature= onwards.
Image displaying SAS Token Connection String in Azure IoT Explorer interface

Screenshot displaying SAS Token Connection String in Azure IoT Explorer interface

Start Configuring the N3uron IIoT Platform

Log into the N3uron IIoT Platform Using a Web Browser

If this is your first time accessing N3uron, open your web browser and type http://localhost:8003. By default, the User and Password are admin and n3uron respectively.

N3uron IIoT platform's WebUI logging interface screenshot

Screenshot displaying the log-in interface within N3uron’s IIoT platform WebUI.

Create a Module Instance Within N3uron’s WebUI Interface

  • Step 01: In the Navigation panel, select Config.
  • Step 02: In the Explorer panel, select Modules.
  • Step 03: Click on the Model menu and select New Module.
  • Step 04: The instance can be given any name but for this example, we will use MQTT.
  • Step 05: Set the Module Type property to MQTT Client. Leave the rest of the properties as their default values and click Save.
Screenshot displaying how to create an instance in N3uron's IIoT platform .

Screenshot displaying how to create an instance using N3uron’s MQTT Module panel.

Configuring N3uron’s MQTT Module within the WebUI’s Explorer Panel

  • Step 01: In the Explorer panel, select the MQTT instance you have just created.
  • Step 02: Click on the Model menu bottom bar and select New Connection.
  • Step 03: Give the new connection a name. In this example, it has been named AZURE.
  • Step 04: Configure the connection properties:
    A: Select Microsoft Azure from the Destination Broker drop-down menu.
    B: In Username, enter the Hostname of your Azure IoT Hub followed by “/” and the name of your device. In our case, this will be N3-IoT.azure devices.net/N3uron_Gateway.
    C: In Password, enter the string you copied from the SAS Token.
    D: In Broker URL, enter the Hostname of your Azure IoT Hub. In our case, this is N3-IoT.azure-devices.net.
    E: Leave the rest of the properties as their default values and click on Save.

Screenshot displaying Azure IoT Hub connection configuration in N3uron’s MQTT module panel.

Now, navigate back to Azure IoT Explorer where, providing that everything has been properly configured, you should see your device connected to your IoT Hub.

Picture Showing Azure IoT Explorer connection with N3uron Node

Screenshot displaying Azure IoT Explorer connection with N3uron Node.

Publish Data Using N3uron’s MQTT Module

  • Step 01: Within the Model panel, right-click on the AZURE Connection you have just configured, select New Publisher, and give it a name. In this example, we will simply use Publisher.
  • Step 02: Click on it and add a name in the Topic field. To publish an MQTT message to Azure, you cannot use any topic name, as it must be named according to the following format devices/{device_id}/messages/events/. In our example, we have used devices/N3uron_Gateway/messages/events/.
  • Step 03: Click on the Tag Filter button, select New Tag Filter, and change the default name. In this example, we have used Filter. Leave Mode, Path, and Regex pattern as their default values.

With this configuration, every tag configured in N3uron will be published to our Azure Broker.

Image displaying the publisher configuration setting within N3uron's MQTT module panel

Screenshot displaying the publisher configuration setting within N3uron’s MQTT module panel.

  • Step 04: In the Explorer panel, select Tags.
  • Step 05: In the Model menu, right-click on the folder icon, select New Tag, and give it a name. In this example, we will use Process_value.
  • Step 06: Within the Configuration panel, set the following properties using the values shown below, leaving the rest of them as their default values:
    Type: Number.
    Simulation/Enabled: Yes.
Picture Showing tag configuration setting within N3uron's MQTT module panel

Screenshot displaying tag configuration setting within N3uron’s MQTT module panel.

  • Step 07: Go to the Azure IoT Explorer and in the Telemetry Tab of your device, you should see the messages being sent by your N3uron node in real-time, as shown in the image below.
Image displaying Azure IoT Explorer interface receiving messages from N3uron

Screenshot displaying Azure IoT Explorer interface receiving messages from N3uron Node.

Subscribe to a Topic Using N3uron’s MQTT Module

  • Step 01: In the Model panel, right-click on the AZURE Connection, select New Subscriber and give it a name. In this example, we will simply use Subscriber.
  • Step 02: Click on it and add a name in the Topic field. Since IoT Hub is not a general-purpose pub-sub messaging broker, it only supports the documented topic names and topic filters. IoT Hub delivers messages with the Topic Name devices/{device_id}/messages/devicebound/, or devices/{device_id}/messages/devicebound/{property_bag} if there are any message properties. In this example, we are going to enter the following string in the Topic: devices/N3uron_Gateway/messages/devicebound/#.
  • Step 03: Set the following properties using the values shown below, leaving the rest of them as their default values:
    – Qos: Qos 0.
    – Encoding: UTF8.
    Compression: None.
    Serialization: JSON.
    Data parser/Type: MqttClient JSON.
Picture showing the subscriber configuration settings in N3uron's MQTT panel

Screenshot displaying the subscriber configuration settings in N3uron’s MQTT panel.

  • Step 04: Within the Explorer panel, select Tags.
  • Step 05: In the Model menu, right-click on the folder icon, select New Tag, and give it a name. In this example, we will use Subscribed_Value.
  • Step 06: In the Configuration panel, set the following properties using the values shown below, leaving the rest of them as their default values:
    – Type: Number.
    – Source/Enabled: Yes.
    – Module Type: MqttClient.
    – Module name: MQTT.
    – Config/Subscriber: Azure/Subscriber.
  • Step 07: Click Save.
Image displaying N3uron's MQTT panel showing subscriber tag configuration settings

Screenshot displaying N3uron’s MQTT panel showing tag configuration settings.

  • Step 08: Go to the Azure IoT Explorer, click on the Cloud-to-device-message tab of your device.
  • Step 09: In the Message Body enter the following in Message Payload:

{

   “/Subscribed_value”: [{

      “v”: 3.14159,

      “q”: 192,

      “ts”: 1630668488618

   }]

}

  • Step 10: Click on the Add system property drop-down menu and select messageid. In the Vaule field enter Test2, as shown below.
Picture displaying cloud-to-device message within Azure IoT Explorer interface

Screenshot displaying cloud-to-device message within Azure IoT Explorer interface.

  • Step 11: Click on the Send message to device button.
  • Step 12: Navigate back to the N3uron WebUI interface and select Data/Real Time from the left-hand panel. You should now see the Subscribed_Value tag you created previously with a value of 3.14159.
Picture showing real-time values in N3uron's MQTT panel

Screenshot displaying real-time values in N3uron’s MQTT panel.

Conclusion on How to Exchange Data with Azure IoT Hub Using N3uron’s MQTT Module

Connecting your assets to Microsoft Azure IoT Hub is extremely easy using N3uron’s MQTT Client module. If you’re ready to go using MQTT, download the N3uron free trial version and read our MQTT Client Manual on how to implement and use N3uron’s MQTT software module on our communication platform. Download the MQTT Client Manual.

Azure IoT HubMQTT

Jose Granero

Jose Granero is Head of Business Strategy and Customer Experience at N3uron Connectivity Systems. He holds a Master of Science degree in Industrial Engineering from the Polytechnic University of Madrid and a Master in Project Management from the School of Industrial Engineers of Madrid. With a strong background in industrial automation and telecommunications, he has performed diverse technical and strategic roles throughout his career, mainly in multinational companies. In his current position, he is focused on customer and partner success, company strategy and product management.

Follow on LinkedIn

    Sign-up for our newsfeed and get blog updates sent straight to your inbox.

    By clicking “Sign Me Up,” you agree to the Term of Use and the submission and processing of your data. Privacy Policy.

    Want to stay up-to-date with us?

    Sign up for our News Feed.

    By clicking "Sign Me Up", you agree to the Terms of Use and the submission and processing of your data. Your privacy is important to us. We will never sell or rent your information. Privacy Policy.

    Privacy Settings
    We use cookies to enhance your experience while using our website. If you are using our Services via a browser you can restrict, block or remove cookies through your web browser settings. We also use content and scripts from third parties that may use tracking technologies. You can selectively provide your consent below to allow such third party embeds. For complete information about the cookies we use, data we collect and how we process them, please check our Privacy Policy
    Youtube
    Consent to display content from - Youtube
    Vimeo
    Consent to display content from - Vimeo
    Google Maps
    Consent to display content from - Google
    Spotify
    Consent to display content from - Spotify
    Sound Cloud
    Consent to display content from - Sound