MQTT Sparkplug Auto-Discovery Using PLCnext Gateway, HiveMQ Broker and Ignition SCADA

MQTT Sparkplug Auto-Discovery Using PLCnext Gateway, HiveMQ Broker and Ignition SCADA

author portrait

Written by Kudzai Manditereza

Category: HiveMQ

Published: August 8, 2022


In this article, I’m going to demonstrate how to generate MQTT Sparkplug telemetry data from a PLCnext Programmable Logic Controller, transmit the data to a HiveMQ Cloud MQTT broker and visualise the information using the Ignition SCADA platform.

To demonstrate, I’m going to use this PLCnext Technology Starter Kit which consists of a controller, I/O modules, potentiometer, and some buttons. I am going to collect data generated by the potentiometer and buttons, publish them as Sparkplug messages to a HiveMQ Broker hosted in the cloud. And on my PC, I’m running an Inductive Automation’s Ignition Gateway which will connect to the HiveMQ Broker and pull all the data for visualization.


One of the biggest challenges in integrating data from industrial data sources is the ability to automatically discover components that are producing the data. The simplest way to achieve that, is to connect my data sources to an MQTT Sparkplug network. In this demo, I’m going to showcase how, using an MQTT Engine Module, the Ignition SCADA platform can automatically discover my PLCnext Controller and visualize the telemetry data that it is generating.

To enable my PLCnext Controller to participate in an MQTT Sparkplug Network, I’m going to deploy onto the controller, a PLCnext Edge Gateway, which is a software runtime that effectively turns my controller into a Sparkplug Edge of Network Node. For coordination of the discovery process and exchange of information, both components are going to be connected through a cloud-based HiveMQ MQTT Broker.

Installing PLCnext Edge Gateway

To deploy the PLCnext Edge gateway, go to the Phoenix Contact website:

Once on this page, I can then download the PLCnext Edge Gateway installer.

Next, I’ll make sure my controller is on the same network as my computer and then run the installer.

I’ll Enter the IP address of my controller into the Axiocontrol IP address field.

And then I’ll enter the admin password of my controller.

Then click Next.

Okay, my connection is successful.

Next, I select the Install via Web option to download and transfer the latest version of PLCnext Edge Gateway onto my controller.

Once the PLCnext Edge Gateway has finished installing, we can go ahead and open the web interface.

I’ve entered the IP address of my controller to access my PLCnext Edge Gateway interface.

And when the interface has loaded, I then click on ADD under drivers at the bottom to add my Sparkplug driver. Then I enter my password.

These are the drivers that are currently available for me to enable.

I enable Sparkplug, and then open my Sparkplug driver interface.

This is where I enter my Sparkplug details which include the broker URL address, its credentials and the Sparkplug topic namespace.

But first, let’s provision my HiveMQ Cloud Broker to get the broker details.

Setting Up HiveMQ MQTT Broker

I need to setup my HiveMQ MQTT Broker on HiveMQ Cloud so that I can point my PLCnext Edge Gateway to this broker and start publishing Sparkplug messages to it.

With the HiveMQ website on my browser I’ll proceed by selecting Cloud on the menu, and then click on HiveMQ Cloud in order to access the HiveMQ Cloud Portal.

When the HiveMQ Cloud page is open, scroll down to the options table. Here I’ll sign up for the free version which allows me to connect up to a hundred devices.

Click on sign up now.

I’m taken to the HiveMQ Cloud portal home page and I sign up using my Google account.

Here I can select a Cloud provider where I want my HiveMQ Broker Cluster to be hosted.

I’ll select AWS.

Next, I need to set up credentials that MQTT clients can use to connect to this broker.

I’ve successfully created a free HiveMQ Cloud account.

When I click on Clusters option on the side menu, a broker cluster has been automatically provisioned for me.

To start publishing to this MQTT broker, I’ll need to get the broker details to put on my PLCnext Edge Gateway.

To do that, I’ll click on Manage Cluster, and then copy my MQTT broker hostname or URL address.

Notice that communication with this broker is secured using TLS encryption at port 8883.

In case I need to update my MQTT client access credentials, I’ll click on Access Management.

Here I can delete the existing username and password and assign new access credentials.

The MQTT Broker setup on HiveMQ Cloud portal is complete. The next step is to configure my PLCnext Gateway to start publishing Sparkplug telemetry messages to my HiveMQ MQTT Broker.

Configuring PLCnext Edge Gateway

Going back to my PLCnext Edge Gateway interface, I’ll go ahead and input my HiveMQ Broker URL address and access credentials that were created.

Then click on submit.

So, I’ve successfully added a Sparkplug Driver to my PLCnext Edge Gateway, and the status of the driver is Connected.

Now that I’ve succesfully connected the Sparkplug driver to my HiveMQ MQTT Broker, the next step is to configure the metrics that the Sparkplug driver needs to push to the broker.

To do that, I’ll click on the driver.

Click the button to add a new metric.

Select Data Source.

Select Downstream.

Iif I had my gateway connected to downstream Modbus devices, for example, they’d show up here and I’d add their data as Sparkplug metrics. But in my case, my source of data are IO modules on my PLCnext controller.

So I’ll select Axioline. Go to Modules. Go to My Analog Input Module. Channel 1. And I have a voltage value.

If I move the slider on the Starter Kit, the value of voltage changes.

I’ll select it,assign it a name, Voltage. I’ll specify the data type as rea and select to update on change. Then I’ll click on submit to add the metric.

I’ve added the digital input switches as well.

Testing the MQTT Sparkplug Network

This means I should be publishing Sparkplug messages to my HiveMQ Broker whenever a change is detected in any one of the metrics. But before I connect my Ignition Platform to the MQTT Broker, I need to test if I am indeed publishing Sparkplug messages.

To do that, I’m going to use an MQTT client software that is compatible with Sparkplug, called MQTT.fx.

I’m already connected to my HiveMQ Broker using MQTT.fx, so I’ll subscribe to receive all Sparkplug messages that are being pushed to my MQTT broker.

When I move my potentiometer, the value changes.

And when I push one of the buttons, it updates with changes.

Next, set up the Ignition platform to connect to my HiveMQ Broker, receive the Sparkplug messages, and then visualise them.

Auto-Discovery and Visualisation Using Ignition Platform

I open my Ignition SCADA platform running on my PC to subscribe to my HiveMQ Broker, receive the Sparkplug messages that are being published from the PLCnext Edge Gateway and visualise the information.

My Ignition Gateway is running at localhost, port 8088

Next I configure an MQTT module from Cirrus Link called MQTT Engine.

By simply inputting my HiveMQ Cloud Broker details, the MQTT Engine will connect to the broker, automatically discover the data being published by my PLCnext Edge Gateway, and pull all the metrics in their respective folder structures.

Going to my MQTT Engine, I’ll select config here.

Scroll down, and click on Settings, under MQTT Engine.

My MQTT Engine is already enabled.

Next, I’ll go to my servers tab.

And this is where I need to put my HiveMQ Cloud MQTT Broker details.

I’ll create a new MQTT server.

I fill in my HiveMQ Broker details and click on Create MQTT Server.

Now, my MQTT Engine is configured and will automatically pull all the tags that are currently being published to my HiveMQ Broker.

To views those tags, I need to open Ignition Designer software.

I’ll open my Ignition Designer Software and then go to my tag browser and select MQTT Engine.

If I look under my Edge Nodes here, I’ll see that MyDemoRoom GroupID which I created on my PLCnext gateway is already appearing.

If I expand that, I can see PLCnextStarterKit, which is the EdgeNodeID that I assigned to my PLCnext Edge Gateway.

And if I expand that I can see my Client or DeviceID, and under that are all of my metrics that I’m publishing from my PLCnext Sparkplug Edge of Node.

All of this hierarchical information is retrieved by simply providing the MQTT Broker address, and nothing else. And Ignition gateway is able to automatically discover all of this information through Sparkplug.

If I move my potentiometer, the value changes in real-time.

From here I can start building powerful graphics to visualise this information using Ignition’s Perspective module.

To demonstrate that,I’ll create a sample page.

Dragging my voltage metric onto the canvas, I’ll select a slider control to visualise the metric. Then I’ll adjust the scaling accordingly to see my slider move as I adjust the potentiometer on my PLCnext StarterKit.

Next I’ll add my digital switches.

They are updated with changes.


I have successfully built a Sparkplug solution that allows the Ignition SCADA platform to automatically discover data that is being generated by a PLCnext Controller and published to a centralized HiveMQ Broker in the cloud.

I hope this demonstration about real world MQTT for Industry 4.0 was helpful. You can learn more about Sparkplug using our Sparkplug Essentials Guide.

Portrait of Kudzai Manditereza

About Kudzai Manditereza

Kudzai is a Developer Advocate at HiveMQ and the Founder of He is the host of an IIoT Podcast and is involved in Industry4.0 research and educational efforts.

newer posts Enabling Digitization in the Hydrocarbon Processing Industry with MQTT
HiveMQ 4.8.3 Maintenance Release older posts