MQTT
The MQTT module enables connection to an MQTT broker, a server that retains the latest values of topics. New data for a topic overwrites the previous value. You can publish data to update the broker's current values or subscribe to topics to receive notifications when related data changes.
Using MQTT greatly extends SweepMe!'s functionality. It allows data handling outside the program without interfering with measurements, for example, building web apps to monitor status, sending emails post-measurement, or forwarding data to a database for automatic storage.
Graphical User Interface
Mode
Select whether to use the MQTT module for publishing or subscribing.
- publish: Sends data to the MQTT broker.
- subscribe: Receives data from the broker. Call the module regularly in your sequencer (e.g., within a Loop) for continuous updates.
Host
Enter the MQTT broker's IP address (e.g., localhost if running locally, 192.168.0.102 for IPv4, or a domain name).
Port
Most brokers use port 1883 (default). Port 8883 is commonly used for TLS encrypted communication. Contact the administrator if it fails.
Protocol
The MQTT protocol version: MQTTv311 (default), MQTTv31, or MQTTv5.
Topic
Enter the base topic for the module; it prefixes all data sets. Supports subtopics like "main/sub/subsub". Leading and trailing slashes are handled automatically.
See publishing or subscribing sections for details.
Quality of Service (QoS)
Select the level in the field "Quality". MQTT supports three QoS levels for data exchange reliability.
| QoS Level | Description | Use Case |
|---|---|---|
| 0 (At most once) | Sent once; no retry on failure. | Frequent, loss-tolerant data with stable connections. |
| 1 (At least once) | Sent again until the broker acknowledges it; duplicates are possible. | Ensures delivery; duplicates acceptable. |
| 2 (Exactly once) | Handshake ensures single delivery. | Critical data (e.g., database storage without duplicates or loss). |
Retain
(Publish only) Retained messages are stored by the broker as the last known good value and sent immediately to new subscribers.
Authentication and security
Expand this section to enter the access data of the broker:
- User and Password: the credentials if access is restricted. The password is not saved in the sequence file. If "remember" is checked, the password is stored encrypted for your Windows user account on this computer, so that you do not need to enter it again in each session.
- TLS: enables SSL/TLS encryption. Brokers typically use port 8883 for TLS.
- Client ID: optional, only needed together with a client certificate.
- Certificate and Key file: optional certificate (e.g. .pem) and key file for client certificate authentication.
Publishing
In mode "publish", the list "Variables" shows the variables of all modules in the branches that contain the MQTT module, grouped by module. Select the variables to publish with the check boxes in the column "Publish" or use "all/none" to select or deselect all of them. The full topic combines the base Topic with each variable's subtopic, which can be edited in the column "Subtopic" (by default the name of the variable). Right-click a variable to copy its topic.
Subscribing
In mode "subscribe", enter the number of topics you would like to subscribe to in the field next to "Variables". For each topic, define the variable name, the unit, the subtopic, and the data type (String, Float, Integer, Boolean, or Timestamp) into which the received message is converted. Timestamps are expected in ISO format, e.g. "2026-10-27T14:30:00". The rows can be reordered by drag and drop.
The module returns the latest values received from the broker as its variables. Call the module regularly in your sequencer, e.g. within a Loop, to get continuous updates.
MQTT Brokers
Mosquitto (https://mosquitto.org/), a free open-source broker from the Eclipse Foundation, runs locally (localhost) for testing or on a central machine (e.g., Raspberry Pi) in production, using its IP address.
Test broker: https://test.mosquitto.org/. Avoid sensitive data, as it's publicly accessible.
Node-RED Integration
Node-RED (https://nodered.org/) can be used to create browser-based user interfaces for MQTT data.