MQTT client
An MQTT client connector reads tags from MQTT brokers (Mosquitto, HiveMQ, EMQX, AWS IoT, Azure IoT Hub and others). One connector can hold several brokers: each broker is a device of the connector, with its own connection, status and tags, and counts as one device for a licence with a device limit.

| Setting | Meaning |
|---|---|
| Host, Port | The broker's host name or IP address. 1883 for plain MQTT, 8883 with TLS |
| MQTT version | 3.1.1 (most brokers) or 5 |
| Client ID | Must be unique on the broker. Empty: wiconnector-<connector>-<broker> |
| Session | Clean starts fresh on every connect. Persistent asks the broker to keep QoS 1 and 2 messages while WiConnector is away |
| Sign in | Anonymous, or user and password (stored encrypted) |
| Keep alive, Timeout, Reconnect after | How often the connection is checked, how long to wait for the broker, and the wait before connecting again after a lost connection |
| TLS | Encrypts the connection. CA certificate: for a broker whose certificate comes from your own CA (empty: the computer's trusted CAs). Client certificate and Client private key: for brokers that sign clients in by certificate (AWS IoT, Azure IoT Hub). Broker certificate: Verify (recommended) or Accept any (self-signed brokers on a closed network). Browse uploads the files from your computer |
| Discover topics, listens for | What Browse listens to (# for everything, plant/# for one branch) and for how long |
Subscription groups take the place of poll groups: brokers push messages, so there is no rate. A group sets the
QoS the tags subscribe with (0, 1 or 2) and Stale after: a value with no new message for that many seconds
goes Uncertain (reason Stale); 0 never. Leave it at 0 for topics that only send changes, such as a retained state.
MQTT tag addresses
The address is the topic, then optional parts separated by ;. Press the i next to the address for examples.
| Address | Reads |
|---|---|
plant/line1/temperature | The whole message: a number, true/false/on/off/1/0, or text for String tags |
plant/line1/data; json=$.temperature | A field of a JSON message {"temperature": 21.5} |
plant/line1/data; json=$.values[2] | The third item of an array; $['field name'] for names with spaces or dots |
sensors/tank1; json=$.level; ts=$.time | With the time from the message (ISO 8601, or Unix seconds or milliseconds) instead of the time it arrived |
plant/pump1/state; write=plant/pump1/cmd | Writes publish the value to the command topic |
plant/line1/setpoint; retain=true | Writes publish to the same topic as retained messages |
A tag reads one topic: wildcards (+, #) are only for Discover. Writes send the value as plain text (21.5,
true) with the subscription group's QoS. Before the first message a tag is Bad WaitingForData; when the broker is
lost, its tags go Bad CommFailure and WiConnector reconnects. A message that does not fit the tag is Bad BadValue,
NotJson or JsonPathNotFound.
Adding tags from a broker (Discover)
In Tag Management, open a group and press Add from broker (or Browse next to a tag's address). WiConnector
listens to the broker for a few seconds and lists every topic that sent a message, with each field of JSON messages
as its own entry (plant/line1/status/motor/current becomes plant/line1/status; json=$.motor.current). Tick the
topics or fields and press Add tags: each becomes a tag with a guessed type (numbers Float64, true/false Bool,
other text String) that you can change. Retained messages show at once; topics that publish rarely only show if they
send something while Discover listens, so raise Discover listens for if some are missing.
Sparkplug B (reading edge nodes)

The MQTT client connector is also a Sparkplug B host application: it reads metrics from Sparkplug B edge nodes
(Ignition, Cirrus Link, Tahu-based gateways, other WiConnectors with a Sparkplug publisher, and so on) on the same
broker. A Sparkplug tag's address starts with spb::
| Address | Reads |
|---|---|
spb:Plant/Edge1:Site | Metric Site of edge node Edge1 in group Plant (a node metric) |
spb:Plant/Edge1/Line1:Motor/Speed | Metric Motor/Speed of device Line1 of that edge node |
Everything after the colon is the metric name, so names with / work. You rarely type these: Add from broker
lists Sparkplug edge nodes under spBv1.0 → group → edge node → device, with each metric's Sparkplug type and the
tag type it becomes (Int8/Int16/UInt8 → Int16, Int32 → Int32, Float → Float32, Double/Int64/UInt64/DateTime → Float64,
Boolean → Bool, String/Text → String). Discover asks edge nodes that only send data for a rebirth, so their names show.
How values arrive:
- Before the edge node's birth a tag is Bad
WaitingForBirth. On connect WiConnector asks every edge node its tags read for a rebirth (NCMDNode Control/Rebirth), because births are not retained. NBIRTH/DBIRTHgive each metric's name, alias, type and current value. A metric the birth does not have is BadNotInBirth.NDATA/DDATAupdate the tags, by name or by alias (data usually only carries aliases). The metric's own timestamp is used, and itsQualityproperty: 192 Good, 64 to 191 Uncertain, below 64 Bad. Historical metrics are skipped.DDEATHmakes the device's tags BadDeviceOffline;NDEATHmakes all the edge node's tags BadEdgeOffline. A death with an olderbdSeqthan the last birth is ignored (the node is already back).- A gap in
seq(lost messages), data before a birth, or an unknown alias asks for a rebirth again (at most every 5 seconds until a birth comes).
Writes to a writable Sparkplug tag send a command: NCMD for node metrics, DCMD for device metrics, with the
metric's name, alias and the type from its birth. A write before the birth fails with No birth seen yet.
Each broker has a Sparkplug B section:
| Setting | Meaning |
|---|---|
| Rebirth requests | Ask for rebirths (default) as above, or Wait for births: never send commands to edge nodes, wait for their own births |
| Primary host ID | Optional. When set (for example scada), WiConnector publishes the retained Sparkplug 3.0 spBv1.0/STATE/<id> {"online": true, ...} on connect, and online: false as its last will and when it stops. Set it only when edge nodes are told to wait for this host as their primary host |
Sparkplug B tags use the subscription group's QoS and stale time like other MQTT tags. The simulator includes an edge
node: group Sim, edge node Plant1, device Line1 (Speed, Count, Running, Temperature, and a writable Setpoint).