How-to
Setting up Sparkplug B on an edge gateway controller
Short answer
Sparkplug B runs on the 1152 and 2152 through the Sparkplug driver in PLCnext Edge Gateway, installed from the web with the Edge Deployment tool. Back up the PLCnext project first: the install forces 2022 LTS firmware and a type 1 reset that wipes it. Expose tags by marking them HMI and enabling the PLCnext API, then validate NCMD and DCMD writes and test store-and-forward before go-live.
On this page
- Can a 1152 or 2152 controller run Sparkplug B?
- What does the Edge Gateway install change on the controller?
- How do I install the Sparkplug driver from the web?
- Why do my PLC tags not show up as data sources?
- How does a Sparkplug metric bind to a data source?
- Do NCMD and DCMD writes reach the PLC tag?
- Does the gateway buffer data through a network outage?
- What if the gateway stops after adding an upstream connection?
- Questions asked
Yes — the 1152 and 2152 controllers run Sparkplug B through the Sparkplug driver inside the PLCnext Edge Gateway software, deployed by the PLCnext Edge Deployment application against any MQTT broker at version 3.1.1 or greater. Three conditions decide whether that setup survives production. The installer forces the controller to 2022 LTS firmware and a type 1 reset that deletes the PLCnext project, so the backup comes first. PLC tags appear as gateway data sources only after HMI marking and the PLCnext API. And neither the NCMD/DCMD write path nor store-and-forward is trustworthy until you have tested both end to end, because a write regression has been reported and buffering is unconfirmed.
Can a 1152 or 2152 controller run Sparkplug B? #
Yes. The Sparkplug B driver runs inside the PLCnext Edge Gateway software, which deploys to the 1152 and 2152 controllers and publishes to any MQTT broker at version 3.1.1 or greater; standard MQTT publishing alone does not give you Sparkplug B.
The driver exists only as part of the Edge Gateway layer: release information traces it from an early alpha through a web-installable beta into an official Edge Gateway update, so what you get depends on the installer build you download, not on the controller hardware. The deployment details name the 1152 and 2152 and no other target. If you were also asked about an Edge computer, that model is not covered by them, so confirm it through Phoenix Contact support before specifying it. Sparkplug B is a specification layered on top of MQTT, not a feature of MQTT itself, which is why raw publishes from PLCnext code cannot substitute for the driver.
What does the Edge Gateway install change on the controller? #
The installer forces the controller to the 2022 LTS firmware the Edge Gateway is tested against, deletes the existing PLCnext project, and performs a type 1 reset that returns the IP address to default — so back up the project and record the network settings before you start.
The Edge Gateway application is tested only against LTS 2022.0 of the PLCnext Runtime, and the installer deliberately installs the newest release it is tested for. A controller running 2022.3 therefore goes down to LTS 2022.0; that downgrade is reported installer behavior, and the release information gives the reason: 2022.3 was still under test, so the tool installs the latest version it is tested for, which is always at least LTS. Decision: if the controller has to stay above LTS 2022.0 for another application, the Edge Gateway install is not compatible at that release stage — schedule it only when the controller can run the LTS baseline, and plan the maintenance window around the project reload.
How do I install the Sparkplug driver from the web? #
Use the Edge Deployment application's install-from-web option: remove any older deployment tool first, install the current one, target the 1152 or 2152, run the web install, then restore the project you backed up with PLCnext Engineer.
- Back up the PLCnext project with PLCnext Engineer, and export the gateway configuration if one exists — the Sparkplug driver documentation states its configuration is retained and exportable.
- Record the controller's IP address, subnet and router; the reset returns them to default.
- Uninstall the older Edge Gateway deploy tool, then install the current PLCnext Edge Deployment application.
- Target the 1152 or 2152 and select install from web. The firmware step moves the controller to 2022 LTS and deletes the existing project.
- If the tool hangs at "Resetting Device", the IP reset dropped the connection: reconnect using the reset network state, close the incomplete deployment session, and run the installation again. The second pass skips the firmware step.
- Reload the backed-up project with PLCnext Engineer and confirm the Sparkplug driver is listed in the gateway configuration.
Nothing in the process takes the controller out of PLCnext use: the PLCnext Runtime stays installed, and you can keep programming and reprogramming with PLCnext Engineer on a controller running the Edge Gateway.
Why do my PLC tags not show up as data sources? #
Unconfigured PLCnext program variables never reach the gateway. Mark every tag you want to publish as HMI, enable the PLCnext API, and disable the custom "user level" system on the PLCnext side; the HMI tags then appear as selectable Edge Gateway data sources.
That matches the reported field symptom: a fresh gateway exposes I/O channels only, and PLC program tags stay hidden until those three PLCnext-side settings are in place. Make the changes in PLCnext Engineer, write the project, then reopen the gateway's data-source picker and confirm the marked tags are listed before you create any metrics. Decision: if tags are still missing, the cause is on the PLCnext side — check the HMI marking, the API and the "user level" system again before touching the gateway configuration.
How does a Sparkplug metric bind to a data source? #
When you create a metric you choose one data source — a PLC tag, a Modbus tag, a dashboard metric, a system tag or an I/O channel — and the driver publishes that source's value; adding the metric triggers a rebirth and subscribes the client to its NCMD and DCMD commands.
Metrics are read/write by default at the Sparkplug layer, but the bound source still decides: publication reads the source, and a command arriving from the broker is written back to that same source, which can reject it — a digital input, for example, is protected from being written by the gateway. Adding a metric fires exactly one rebirth; a rebirth that repeats after that is a receiver-side fault, covered in resolving continuous Sparkplug rebirth from the Ignition MQTT Engine. Before forcing a rebirth manually from the SCADA side, read when to use the Sparkplug rebirth tag on an edge node.
Do NCMD and DCMD writes reach the PLC tag? #
Yes — when a command arrives on NCMD or DCMD, the driver writes the value to the metric's bound data source, so the write succeeds only if that source accepts writes; validate both directions before trusting it, and repeat the test after every driver update.
Run this validation sequence:
- Publish a known value — say 4271 on an integer tag — from the PLC and confirm the metric updates at the broker or SCADA host.
- Write a permitted test value, 4272, back through the metric's NCMD or DCMD path.
- Confirm the bound PLC tag now reads 4272 and that no second metric appeared.
- Repeat all three after every Edge Gateway or Sparkplug driver update.
Run the write steps against a spare point or a plain value tag, never an output wired to live equipment — a misrouted command moves a real actuator.
Step 3 is the one with history. A reported fault had a SCADA write create a new metric and break the loop instead of changing the bound tag. The driver developer's testing found that defect fixed in the release distributed by install from web, but later reports showed the same behavior again, and no release number identifies the correction — so the install method alone proves nothing. Decision: if a broker write creates a new metric instead of changing the bound source, treat the release as affected and keep NCMD and DCMD writes out of production until an update passes all four steps. Commands that never arrive at the controller at all are a different fault class; troubleshooting Sparkplug command losses between the broker and the client covers that diagnosis.
Does the gateway buffer data through a network outage? #
Treat store-and-forward as unconfirmed. Early release information described it as planned rather than implemented, and nothing in the driver documentation confirms a persistent queue, so data changed while the link is down is lost until you prove otherwise with a timed disconnect test.
The specification does define an is_historical payload flag that lets a client backload data, but the flag is optional for the implementer, and no release statement says this driver sets it or keeps a queue. Test the complete sequence instead: disconnect the broker path, change source values while the link is down, restore the link, and count what arrives.
Example: a tag scanned at 1-second intervals with the link down for 10 minutes must deliver 10 min × 60 s/min ÷ 1 s/sample = 600 samples after reconnect. If 600 rows arrive in order and marked historical, the driver buffered the outage. If 1 arrives — the current value only — it did not. What a compliant backfill looks like on the receiving side is described in MQTT store and forward backfill after a connection outage.
Decision: do not approve the architecture on a successful rebirth or live-value recovery alone; the full sample count with ordering intact is the pass condition, sized from your own scan rate and outage duration.
What if the gateway stops after adding an upstream connection? #
One reported fault: after adding an upstream connection to consume broker tags into a PLCnext program, the gateway stopped working and needed a reinstall. No cause, affected release or confirmed fix is documented, so isolate the fault and report it rather than tuning around it.
Keep the project backup current, record the installed Edge Gateway and driver versions with the controller firmware, and reproduce the fault with the smallest possible configuration before submitting it through the support function in the deployment tool. After recovery, verify four boundaries independently:
- PLC-to-gateway tag visibility — the HMI-marked tags appear as data sources.
- Gateway-to-broker publication — metric values update at the broker.
- Broker-to-gateway command reception — an NCMD or DCMD arrives at the driver.
- Gateway-to-PLC writeback — the bound source changes and no new metric appears.
Decision: until a release passes all four boundaries with an upstream connection present, keep the PLCnext program's consumption of broker tags on a separate gateway or version.
Questions asked
Is ordinary MQTT publishing from the controller the same as Sparkplug B?
No. Sparkplug B is a layer on top of MQTT: it defines the topic namespace, birth and death messages, state management and a compact binary payload encoding. A plain MQTT publish from PLCnext code carries none of that, so a Sparkplug SCADA host cannot treat it as a metric. The implemented path here is the Sparkplug driver inside the Edge Gateway, not raw MQTT publishing.
Which broker features does the Sparkplug driver rely on?
Any compliant MQTT broker at version 3.1.1 or greater satisfies the driver. Its documentation lists single-client operation, automatic reconnection, TLS server verification, and configuration that is retained and exportable. Export that configuration before you reinstall, so the broker connection, metric list and data-source bindings survive the reset the installer performs.
What should I collect before reporting an Edge Gateway fault?
Collect the installed Edge Gateway and Sparkplug driver versions, the controller firmware, the smallest configuration that reproduces the fault, and broker-side logs covering the same timestamp. Report the case through the support function built into the deployment tool, which reaches the driver team. Keep the project backup outside the controller until the case is closed.
What does the is_historical flag do?
It is a flag in the Sparkplug B payload that marks metrics as historical, telling the receiving system these values were collected earlier and should be backloaded rather than treated as current. The flag exists in the specification; the PLCnext release information does not confirm the driver sets it while replaying data, which is why the timed disconnect test decides the store-and-forward question.