Skip to content

MQTT

An MQTT connection links Scadora to an MQTT broker: Mosquitto, EMQX, HiveMQ, a cloud broker or a gateway’s built-in broker. One connection works both ways:

  • Client. The connection’s tags subscribe to broker topics and receive values from sensors, PLCs, gateways and other systems. Writing a tag publishes the value back.
  • Publishing. The connection can send any project tag to the broker: tags from S7, Modbus, OPC and internal tags. Node-RED, Grafana, clouds, MES and other SCADA systems pick them up there.

Scadora speaks MQTT 3.1.1, which every broker and device understands.

  1. You need a broker. For a first try, Mosquitto on the same computer will do: install it and it listens on port 1883.

  2. In the editor: Connection → MQTT. Set Broker to the broker address (localhost if it runs on this computer).

  3. Create a tag on this connection with type Float32 and address plant/line1/temperature.

  4. Publish a value from the command line:

    Terminal window
    mosquitto_pub -h localhost -t plant/line1/temperature -m 21.5 -r
  5. Start the project: the tag shows 21.5 with Good quality. The -r (retain) flag asks the broker to keep the last value, so the tag gets it even after Scadora restarts.

Setting Default Meaning
Broker — Broker name or IP address
Port 1883 1883 is unencrypted, 8883 is usually TLS
TLS off Encrypted connection to the broker
Accept any certificate off Do not check the broker certificate: for test benches and self-signed certificates
User, Password empty Broker login; empty means no login
Client ID empty Unique client name. Empty means scadora-<computer>-<connection>
QoS 1 Delivery guarantee for subscriptions, writes and publishing: 0, 1 or 2
Keep alive, s 30 How often to check the connection to the broker
Timeout, ms 10000 How long to wait when connecting to the broker
Stale after, s 0 If a tag’s topic gets no messages for longer, the tag goes to “no connection”. 0 means do not check

The connection’s Poll cycle, ms sets how often new messages reach the tags: the broker delivers messages at once, and they are applied to tags once per cycle. 200–1000 ms is enough for MQTT.

Setting Default Meaning
Write topic {topic} Where tag writes are published. {topic} is the tag’s topic, for example {topic}/set. Empty disables writing to this connection’s tags
Retain on write off The broker keeps the written value
Boolean values true / false How Bool is written: true/false, 1/0 or ON/OFF. Applies to writes and to publishing
Setting Default Meaning
Publish tags off Send project tag values to the broker
Publishing root topic scadora Values go to <root>/<tag name>, the state to <root>/status
Tables to publish empty Tag table names separated by commas; empty means all
Name filter empty Name masks separated by commas: Line1.*, Tank?_Level; empty means all tags of the selected tables
Publishing format Value only Value only, or JSON with value, quality and time
Name dots become topic levels on Line1.Pump1.Speed → <root>/Line1/Pump1/Speed
Retain on publish on The broker keeps the last value of every tag
Republish every, s 0 Publish everything again with this period; 0 means on change only
Commands from the broker off Accept writes to published tags through <tag topic>/set

The address is the topic the tag subscribes to. If the message is JSON, the field goes after #. If the device takes commands on another topic, put it after >.

topic
topic#field
topic#field>write topic

MQTT address panel

Address What is taken
plant/line1/temperature The whole message: 21.5, true, ON, text
zigbee2mqtt/sensor#temperature Field temperature of {"temperature":23.4,"humidity":51}
tele/pump/SENSOR#ENERGY.Power Nested field: {"ENERGY":{"Power":120}}
sensors/line1#values[0] Array element: {"values":[5,7]} → 5
stat/pump/POWER>cmnd/pump/POWER State is read from stat/…, writes go to cmnd/…

Wildcards + and # are not allowed in a tag address: one tag, one topic. Several tags can read different fields of the same topic; the broker still sends the message once.

  • Number — with a dot as the decimal separator: 21.5, -3, 1e3. Integer types round fractions. A value outside the type’s range (say, 70000 for Int16) makes the tag quality Bad.
  • Boolean — true/false, 1/0, ON/OFF, yes/no, open/closed in any case, and any number (0 is false).
  • String — the whole message as is.
  • A JSON field is found by its dotted path, first with exact case, then ignoring case (Temperature finds temperature). A JSON boolean in a numeric tag gives 1 or 0.
  • A Scadora JSON message ({"value":12.5,"quality":"Good",…}) is read without naming a field: value is taken. This way one Scadora reads data published by another.

Tag quality:

Quality When
No data No message has arrived on the topic yet
Good The message was parsed; the value time is when the message arrived
Bad There is a message but it does not fit: no JSON field, text instead of a number, out of range
No connection No connection to the broker, or “Stale after” has fired
Config error The tag address could not be parsed (empty topic, wildcards)

The broker sends retained messages right after subscribing, so tags get their last values as soon as the project starts. Topics without retain show “no data” until the next message.

Writing a tag (by an operator, a script or a server task) publishes the value:

  • to the write topic in the tag address, if one follows >;
  • otherwise to the connection’s Write topic, with {topic} replaced by the tag’s topic.

If the address has a JSON field, an object with that field is published. For example, tag zigbee2mqtt/valve#state with Write topic {topic}/set and boolean values ON / OFF writes {"state":"OFF"} to zigbee2mqtt/valve/set. A nested field a.b gives {"a":{"b":42}}. Writing to an array element is not supported.

If the write topic is the same as the read topic (the default {topic}), the broker echoes the written value back to Scadora and the tag shows it at once. A device that publishes its state on the same topic confirms or corrects it.

Turn on Publish tags and the connection sends project tag values to the broker on every change.

  • What is published: tags of the Tables to publish (empty means all) that match the Name filter (empty means all). The MQTT connection’s own tags are not published, to avoid a loop. System tags @… are published only when named in the filter, for example @Connection.*.

  • Where: <root>/<tag name>. With Name dots become topic levels on, tag Line1.Pump1.Speed goes to scadora/Line1/Pump1/Speed, and a subscriber can take the whole line with scadora/Line1/#.

  • “Value only” format: 42.5, true, text. An unreliable value (Bad, no connection) is not sent; the broker keeps the last good one.

  • JSON format: always sent, with the quality:

    {"value":42.5,"quality":"Good","timestamp":"2026-11-18T10:00:00.000Z"}

    When the PLC connection is lost, subscribers see {"value":null,"quality":"CommFailure",…}.

  • Scadora state: online is published to <root>/status on connect and offline on stop. If the server disappears without disconnecting (power, network), the broker itself publishes offline: this is MQTT’s “last will”.

  • Broker connection lost: changes do not pile up, only the last value of each tag is kept. Once the connection is back, Scadora publishes everything again.

  • Retain on publish (on by default) lets a new subscriber get current values at once, without waiting for changes.

To see what is being published:

Terminal window
mosquitto_sub -h localhost -t "scadora/#" -v

With Commands from the broker on, an external system can write a published tag by sending a value to <tag topic>/set:

Terminal window
mosquitto_pub -h localhost -t scadora/Line1/Pump1/Start/set -m 1

Commands are accepted only for tags with Operator write access. Tags with write access “Engineer only” or “Disabled” ignore them. The value is parsed by the same rules as for reading and written like any other write: to the PLC through its connection, or into memory for an internal tag. The write appears in the server log.

Sparkplug B devices and gateways (Ignition Edge, Cirrus Link, Opto 22 and others) are read through the same MQTT connection. Tag address:

Address Meaning
spb:Group/Node:Metric A metric of an edge node
spb:Group/Node/Device:Metric A metric of a device behind the node

For example, spb:Plant1/Edge1:Inputs/Temperature or spb:Plant1/Edge1/Pump3:Speed. A metric name may contain “/”, so it is separated by a colon.

  • Scadora subscribes to the spBv1.0/… topics of the nodes it needs, learns the metrics from NBIRTH and DBIRTH messages (names, aliases, types) and takes values from NDATA and DDATA, by name or alias.
  • NDEATH and DDEATH put the tags of the node and its devices into “no connection”.
  • After connecting, and on an unknown alias, Scadora asks the node to send its BIRTH again (Node Control/Rebirth).
  • Writing a tag sends an NCMD command to the node or a DCMD command to the device, with the metric type from the BIRTH.

A sensor publishes zigbee2mqtt/kitchen_sensor with JSON like {"temperature":23.4,"humidity":51,"battery":87}; a relay takes commands on …/set.

Tag Type Address
Kitchen.Temp Float32 zigbee2mqtt/kitchen_sensor#temperature
Kitchen.Humidity Float32 zigbee2mqtt/kitchen_sensor#humidity
Kitchen.Battery Int16 zigbee2mqtt/kitchen_sensor#battery
Pump.Relay Bool zigbee2mqtt/pump_relay#state

In the connection: Write topic {topic}/set, Boolean values ON / OFF. Writing Pump.Relay = true sends {"state":"ON"} to zigbee2mqtt/pump_relay/set.

Tag Type Address
Pump.Power Float32 tele/pump/SENSOR#ENERGY.Power
Pump.Energy Float64 tele/pump/SENSOR#ENERGY.Total
Pump.Relay Bool stat/pump/POWER>cmnd/pump/POWER

Boolean values ON / OFF. Tasmota sends tele/…/SENSOR once per telemetry period (5 minutes by default). You can shorten it with the TelePeriod 10 command and set Stale after above that period.

The device publishes numbers to separate topics:

factory/boiler/temp → 68.4
factory/boiler/burner → 1

Tag addresses match the topics. To change a setpoint from a screen, create tag factory/boiler/setpoint and have the device subscribe to that topic.

Turn on publishing with JSON format and root plant, and choose the tables. In Node-RED, an mqtt in node with topic plant/# receives every tag. In Grafana, add an MQTT data source or store the data in InfluxDB through Telegraf.

  • On a network you do not fully control, use TLS (usually port 8883) and a broker login.
  • The Password is stored in the project file as plain text, like the other connection settings. Do not keep a project with a password in a public repository.
  • Accept any certificate turns off broker authentication: test benches only.
  • Topic permissions are set on the broker (ACL). Let the Scadora user read device topics and write only its own.

To watch every message on the broker:

Terminal window
mosquitto_sub -h <broker> -t "#" -v
Symptom Cause and fix
“No connection”, log says “connection refused” The broker is not running, the port is wrong, or the broker does not listen on the network. Mosquitto 2 accepts only local connections by default: add listener 1883 to its configuration
“The broker rejected the connection: NotAuthorized” Wrong user or password, or the broker requires a login
The connection drops every few seconds A second client with the same Client ID
Tag shows “no data” The topic does not match (case matters: Plant ≠ plant), or nothing has been published on it since without retain
Tag is Bad The message has the wrong form: no JSON field, text instead of a number, number out of the type’s range. Check the message with mosquitto_sub
Tag shows “no connection” while the broker is up Stale after fired: the device publishes less often than set
Writes do not reach the device Check Write topic and the boolean format; watch what is sent with mosquitto_sub
Nothing is published Check the tables and the filter; the MQTT connection’s own tags are not published
  • MQTT 3.1.1. With Sparkplug B, Scadora is a host without primary status (it does not publish STATE); datasets and templates are not decoded.
  • One QoS for the whole connection.
  • No wildcards in tag addresses: each field is a separate tag.
  • Scadora is a broker client, not a broker: devices and Scadora connect to a shared broker.