Skip to main content

Send Line 1 to an MQTT broker

What you build​

An Uplink that publishes the poll group fast of the Filler to your own MQTT broker, under an ISA-95 topic such as demo/DEMOFOODS/IZMIR/BOTTLING/LINE1/FILLER/fast. You then read the messages with mosquitto_sub. In the second half you open the read-only public broker of mii Lite and read the same values under mii/uns/#.

Time: about 25 minutes.

Prerequisites
  • You finished Your first pipeline. The device line1-modbus has the group fast with the six Filler tags, bound to the equipment Filler.
  • Docker (to run a Mosquitto broker) and the Mosquitto command line tools (mosquitto_sub) on a computer that can reach the Lite host.
  • You are signed in as a user who may configure uplinks (integration engineer or admin).

Part 1: publish to your own broker​

1. Start a Mosquitto broker​

Mosquitto 2 only listens on the local machine unless you tell it otherwise. Create a small config and start the broker:

mkdir -p ~/demo-broker && cd ~/demo-broker
cat > mosquitto.conf <<'EOF'
listener 1883
allow_anonymous true
EOF

docker run -d --name demo-broker --restart unless-stopped \
-p 1883:1883 \
-v "$PWD/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro" \
docker.io/library/eclipse-mosquitto:2
Lab only

allow_anonymous true is fine for a tutorial on a closed network. In a plant, set a user and password and fill Username and Password in the uplink.

Port 1883 already taken

If you also switched on the public MQTT listener of Lite (part 2) on the same machine, both want port 1883. Map the broker to another port, for example -p 1884:1883, and use that port in the uplink.

The tutorials call the broker demo-broker. Use the IP address of the machine if the name does not resolve from the Lite host.

  1. Open Connectivity → Uplinks and click Add uplink.

  2. In "Choose plugin" select MQTT.

  3. Fill the form "Add uplink":

    FieldValue
    Nameline1-mqtt
    MQTT Version3.1.1 (default)
    QoS Level0 (default)
    Upload Formatvalues-format (default)
    Broker Hostdemo-broker
    Broker Port1883
    Username, Passwordempty for this lab broker
    SSLoff
    Enabledon
  4. Switch on ISA-95 topics (UNS). Set Topic root (optional) to demo. Leave One topic per tag off.

  5. In Subscribe to device groups tick the group fast under line1-modbus.

  6. Check the Topic preview. It should show:

    demo/DEMOFOODS/IZMIR/BOTTLING/LINE1/FILLER/fast
  7. Click Test connection, then Save.

Add uplink: the first step of the uplink form
Add uplink: the first step of the uplink form
The topic uses codes, not names

Every topic segment is the ISA-95 code you typed in the model (DEMOFOODS, IZMIR, Bottling, Line1, Filler), not the display name. A space would become %20. All tags of a group must belong to the same equipment, otherwise the group keeps the default topic /mii/line1-mqtt/line1-modbus/fast.

The Uplinks list shows line1-mqtt with the status Connected and the counter "N sent" rising.

Uplinks list: line1-mqtt connected, sent counter rising
Uplinks list: line1-mqtt connected, sent counter rising

3. Subscribe and read the payload​

mosquitto_sub -h demo-broker -p 1883 -t 'demo/#' -v

Every second you get one message per group:

demo/DEMOFOODS/IZMIR/BOTTLING/LINE1/FILLER/fast {"node":"line1-modbus","group":"fast","timestamp":1764670530123,"values":{"State":1,"Speed":116,"Temperature":4.1,"Pressure":3.21,"GoodCount":14872,"RejectCount":181}}
PartMeaning
nodeThe device name.
groupThe group name.
timestampUnix milliseconds, set by the Site Runtime when it publishes (not the device clock).
valuesOne entry per tag, scaled (Temperature is 4.1 and not 41).
errorsAdded only if a tag could not be read and Upload Tag Error Code is on, for example "errors":{"Pressure":3002}.

Pretty-print one message with jq:

mosquitto_sub -h demo-broker -t 'demo/#' -C 1 | jq .

4. Try one topic per tag​

  1. Edit the uplink and switch on One topic per tag. The Topic preview now lists six topics, for example demo/DEMOFOODS/IZMIR/BOTTLING/LINE1/FILLER/Speed.
  2. Subscribe to a single value: mosquitto_sub -h demo-broker -t 'demo/DEMOFOODS/IZMIR/BOTTLING/LINE1/FILLER/Speed' -v.

Switch it off again when you are done. A rename of any code moves the topic, and the uplink re-subscribes without reconnecting. Uplinks never publish retained messages, so a new subscriber waits up to a second for the first value.

5. Store and forward​

If the broker goes away, the MQTT uplink can cache values: edit the uplink, switch on Offline Data Caching and set Cache Memory Size and Cache Disk Size. Test it with docker stop demo-broker, wait a minute, docker start demo-broker, and watch the older values arrive. The counters "N queued" and "N dropped" under the uplink row show what happened.

Part 2: the public read-only broker of Lite​

mii Lite has its own broker for outside readers. It is closed by default (Docker images open it). It publishes every tag that is bound to equipment under mii/uns/<enterprise>/<site>/<area>/<work center>/<equipment>/<tag>, one message per tag, and a reader cannot write.

1. Open the listener​

Edit C:\ProgramData\MakeIntelligent\config\mii.env and add:

MI_LITE_MQTT_PUBLIC_LISTEN=0.0.0.0:1883

Restart the service, then open the port yourself (the installer opens only 8080):

& "C:\Program Files\MakeIntelligent\mii.exe" stop
& "C:\Program Files\MakeIntelligent\mii.exe" start
New-NetFirewallRule -DisplayName "MakeIntelligent Lite MQTT (1883)" -Direction Inbound -Protocol TCP -LocalPort 1883 -Action Allow

If the public port collides with another Lite port, Lite does not start. The values off, 0, false, no or empty close the listener.

2. Get the login​

When an outside access is open, Lite writes the logins to a restricted file:

# Linux
sudo cat /var/lib/makeintelligent/DATA-ACCESS.txt
# Docker
docker exec mii cat /data/DATA-ACCESS.txt

On Windows open C:\ProgramData\MakeIntelligent\DATA-ACCESS.txt as Administrator. It holds the MQTT user mii-reader and its password.

3. Subscribe​

mosquitto_sub -h <lite-host> -p 1883 -u mii-reader -P '<password>' -t 'mii/uns/#' -v
mii/uns/DEMOFOODS/IZMIR/BOTTLING/LINE1/FILLER/Speed {"value":116,"quality":"good","ts":"2026-12-02T10:15:30.123Z","tagId":"tag_01h8x2k9"}
mii/uns/DEMOFOODS/IZMIR/BOTTLING/LINE1/FILLER/Temperature {"value":4.1,"quality":"good","ts":"2026-12-02T10:15:30.123Z","tagId":"tag_01h8x2ka"}
FieldMeaning
valueThe scaled value.
qualitygood, uncertain, bad or unknown.
tsUTC time, ISO 8601 with milliseconds.
tagIdThe tag id (left out when empty).
errorOnly on a bad read: then quality is bad and there is no value.
Good to know
  • The account mii-reader may read mii/uns/# and nothing else. The internal topics are closed to it.
  • Tags that are not bound to an equipment have no path and are skipped.
  • This feed does not use your own topic root. It is not the same as the uplink option ISA-95 topics (UNS), which uses the root you choose.
  • Messages are QoS 0 and not retained.

Check it works​

  • The Uplinks list shows line1-mqtt as Connected and "N sent" grows every second.
  • mosquitto_sub -t 'demo/#' -v prints one JSON message per second with Speed between 110 and 120 while the Filler runs.
  • Temperature is about 4, not 40.
  • After docker stop demo-broker the status changes to Retrying or Down, and after the start it returns to Connected.
  • Part 2: mii/uns/.../Filler/Speed arrives with "quality":"good".

Next steps​

Troubleshooting​

SymptomLikely causeFix
Uplink status "Error" or "Retrying"Broker unreachable, or wrong host or port.Test with mosquitto_pub -h demo-broker -t test -m hi. Use the IP address.
Connected but mosquitto_sub prints nothingThe group is not ticked in Subscribe to device groups, or the uplink is not enabled.Edit the uplink, tick the group, switch on Enabled.
Topics look like /mii/line1-mqtt/line1-modbus/fastISA-95 topics are off, or the group has tags of different equipment ("tags in this group belong to different equipment").Switch on ISA-95 topics (UNS) and keep one equipment per group.
"no complete ISA-95 path"The tags are not bound to equipment.Bind them in the device (see the first tutorial).
"another uplink on this broker uses this topic"Two uplinks produce the same topic.Change Topic root (optional).
Mosquitto: connection refused from another hostDefault Mosquitto config listens locally only.Use the listener 1883 config above.
Lite does not start after adding the public listenerThe port collides with another Lite port.Choose a free port in MI_LITE_MQTT_PUBLIC_LISTEN.
mii-reader login refusedWrong password, or the listener is closed.Read DATA-ACCESS.txt again. It exists only while an outside access is open.