Heisenware Docs
Go to websiteGet a demo
  • 👋Welcome
  • Getting started
  • Release Notes
    • v84 - Get in the flow
    • v83 - Beauty treatment
    • v82 — Fully distributed
    • v81 — Removing old cruft
    • v80 — Chicks on fire
    • v79 — Nothing is forever
    • v78 — Keep moving
    • v77 — More intelligence
    • v76 — Well cooked
  • Build & Deploy Apps
    • Overview
    • Flow Builder
      • Nodes (Functions)
        • Inputs
        • Trigger
        • Output
      • Function Extensions
        • Modifier
        • Filter
        • Error handler
        • Memorizer
      • Objects & Instances
      • Utilities
        • Basic Functions
        • PDF functions
        • Circular buffer
        • Timer
        • Counter
    • Integrations
      • Protocol Connectors
        • GraphQL
        • HTTP/REST
        • MQTT
        • OPC UA
          • Heidenhain PLCs with OPC UA
        • RS-232/485
        • Siemens S7
      • Data Connectors
        • File
        • Relational Database
        • Time Series Database (WIP)
      • API Connectors
        • OGC SensorThings API
        • Operating System
        • Zebra RFID IoT Connector
      • Agent / (Edge Connector)
      • Calling Custom Code
    • UI Builder
      • Input Widgets
        • Form
        • File Upload
        • Photo
        • Signature
        • Barcode / QR-Code (WIP)
        • Document Scan (WIP)
      • Display Widgets
        • Chart
        • Chat
        • Circular Gauge
        • Data Grid
        • Linear Gauge
        • Map
        • Media View
        • Progress Bar
        • Sparkline
        • Status Lamp
        • Toast
        • Value Box
        • Kanban Board
        • Data Tiles
        • Pie Chart
        • Sankey
      • Buttons
      • Text Box
      • Images
      • Icons
    • Communication Interfaces
      • Email Notifications
      • OPC UA Server
    • Data & File Storage
      • Internal InfluxDB
      • Internal PostgreSQL
      • File Server
    • App Appearance
      • Pages
      • In-App Navigation
      • Screens & Devices
      • Theming
    • Simulation & Testing
      • Simulating Events
      • Simulating Data
    • PDF Templates
    • RAG-based Chatbot
    • Deployment
  • Manage Apps
    • Overview
    • Manage Apps
      • General Settings
      • Users and Access
      • Distribution & Versioning
    • Manage Integrations
    • Manage Account
      • Account Structure
      • Members
      • Workspaces
  • TUTORIALS
    • Build Your First Heisenware App
  • Connect Heidenhain CNC with OPC UA Support
  • Related links
    • Website
    • Privacy policy
    • Imprint
Powered by GitBook
On this page
  • Creating an MQTT instance
  • Creating an MQTT instance
  • Deleting an MQTT instance
  • MQTT functions
  • Connect to an MQTT instance
  • Publish a message
  • Publish a message as JSON
  • Subscribe to one or more topics
  • Convert incoming messages to JSON format
  • Convert incoming messages to String format
  • Output incoming messages in binary format
  • Unsubscribe from a topic
  • End an MQTT connection
  • Check if the connection is alive
  • Check if the connection is being reestablished
  • Output the last message ID
  1. Build & Deploy Apps
  2. Integrations
  3. Protocol Connectors

MQTT

Last updated 7 months ago

MQTT (Message Queuing Telemetry Transport) is a lightweight, publish-subscribe network protocol that transports messages between devices. Designed for constrained environments, it is ideal for machine-to-machine (M2M) or Internet of Things (IoT) scenarios. MQTT operates over TCP/IP and aims to be simple and efficient, ensuring high performance and reliability even on low-bandwidth networks.

In MQTT, topics are used to filter and direct messages between clients. A topic is a string, typically representing a hierarchy, that defines the destination of the message. Topics are case-sensitive and use a forward slash (/) as a delimiter to create levels of hierarchy. For example, home/kitchen/temperature and home/livingroom/humidity are distinct topics.

Creating an MQTT instance

Creating an MQTT instance

The create function creates an MQTT instance with which a client connection to an MQTT broker over an arbitrary transport method (TCP, TLS, WebSocket, ecc) can be . The MQTT client automatically handles the following:

  • Regular server pings

  • QoS flow

  • Automatic reconnections

  • Start publishing before being connected

Simply drag the create function onto the board, name your instance and trigger.

Deleting an MQTT instance

Drag the delete function onto the board, insert the name of the instance to be deleted and trigger it.

MQTT functions

Connect to an MQTT instance

With the connect function, you can connect the MQTT instance to a broker.

To create the connection, drag the connect function onto the board. Insert url: {url} into the url field, where you replace the curly brackets and their content with your URL. The following protocols are supported: mqtt, mqtts, tcp, tls, ws, wss, wxs, alis.

Then, in the second input field, add options: {} as the main key and insert the following parameters in object format in the brackets as needed.

Parameter
Type
Default
Description

username

String

The username required by your broker, if any.

password

String

The password required by your broker, if any.

wsOptions

Object

{}

keepalive

Integer

60

Keep alive interval, set to 0 to disable.

reschedulePings

Boolean

true

Reschedule ping messages after sending packets.

protocolId

String

MQTT

Protocol ID

protocolVersion

Integer

4

Protocol Version

clean

Boolean

true

Set to false to receive QoS 1 and 2 messages while offline.

reconnectPeriod

Integer

1000

Interval between two reconnections in milliseconds. Disable auto reconnect by setting to 0.

connectTimeout

Integer

30000

Time to wait before a CONNACK is received in milliseconds.

queueQoSZero

Boolean

true

If connection is broken, queue outgoing QoS zero messages.

autoUseTopicAlias

Boolean

false

Enabling automatic Topic Alias assign functionality.

resubscribe

Boolean

true

If connection is broken and reconnects, subscribed topics are automatically subscribed again.

Publish a message

With the publish function, you can send a message to a topic. Insert the topic in the first box, the message in the second one and lastly, decide on the options to publish with.

The options need to be constructed as an object, with the highest key being options with the following three parameters nested inside, as needed:

Parameter
Type
Default
Description

qos

Integer

0

Quality of Service level

retain

Boolean

false

dup

Boolean

false

Marks the message as duplicate.

Publish a message as JSON

Subscribe to one or more topics

With the subscribe function, you can subscribe to one or multiple topics. If you only want to subscribe to one topic or with a wildcard, insert the topic in the first input box and the qos setting in the second one. If you want to subscribe to multiple topics, ignore the options box and insert an object into the topic input box in the following scheme:

topic1: {qos: 0}
topic2: {qos: 1}

Topic Wildcards

MQTT supports two types of wildcards for subscribing to multiple topics:

  1. Single-level wildcard (+): Matches exactly one topic level. For instance, home/+/temperature matches home/kitchen/temperature and home/livingroom/temperature.

  2. Multi-level wildcard (#): Matches all subsequent levels. For example, home/# matches home/kitchen/temperature, home/livingroom/humidity, and any other topic starting with home/.

Using these wildcards, you can flexibly subscribe to a range of topics.

Convert incoming messages to JSON format

The onJsonMessage function needs to be triggered once after the app is started to start listening to events. It then converts the received events into JSON objects.

Convert incoming messages to String format

The onStringMessage function needs to be triggered once after the app is started to start listening to events. It then converts the received events into strings.

Output incoming messages in binary format

The onBinaryMessage function needs to be triggered once after the app is started to start listening to events. It leaves the received events in binary format.

Unsubscribe from a topic

With the unsubscribe function, you can remove a subscription by inserting the topic name in the input field and triggering.

End an MQTT connection

With end, you can disconnect from the MQTT broker. The disconnect may take a second, but can be forced to immediately happen, without waiting for the inflight messages to be handled, by inserting forced: true in the input field.

Check if the connection is alive

isConnected simply returns true if a connection to an MQTT broker is open and false if not.

Check if the connection is being reestablished

With isReconnecting you can check if the client is currently trying to reconnect to the MQTT broker. A reconnection in progress is indicated by true.

Output the last message ID

You can output the message ID of the last message sent by the client with getLastMessageId.

Specific options for WebSockets. Have a look at: .

Whether to retain the message or not. For an explanation of retained messages, see .

The publishJson function works in the same way as the function, but delivers a JSON message instead. Therefore, in the second input field, you should insert a JSON object.

publish
https://github.com/websockets/ws/blob/master/doc/ws.md
here
created
Create an MQTT instance
Delete an MQTT instance
Checking if MQTT connection is open
Checking if MQTT connection is being reestablished
Readout of last MQTT message ID