Skip to main content
Protocols · MQTT

Publish and subscribe to any MQTT broker, one block at a time.

AppBlocks has a built-in MQTT client. Point it at your broker, then send sensor data and receive commands with ready-made blocks. There’s no client library to integrate.

Supported

A complete MQTT client, ready to use.

Any broker

Connect to your own broker or a cloud service: set the server, port, client ID, and credentials.

TLS

Use port 8883 for encrypted connections, or 1883 for plain TCP.

Publish

Send readings and events to any topic with the MQTT Publish block.

Subscribe with wildcards

Receive messages on topics with + and # wildcards, stored straight into a variable.

Connection events

React when the broker connection comes up or drops, for example to publish a status message.

Settings in the field

Link broker settings to device settings, and change them from the Web Console or mobile app.

Common patterns

Telemetry out, commands in.

Send telemetry when values change

Publish a reading whenever a variable changes, or on a timer. Use On MQTT Change to announce the device when it connects.

  • MQTT Publish to any topic
  • QoS 0, 1, or 2
  • Triggered by variables, timers, or any event
MQTT Publish block
On Variable Changedtemperature
MQTT Publishgreenhouse/zone2/temperature
On MQTT ChangeConnected
MQTT Publishgreenhouse/zone2/status = online

Receive commands from your back end

Subscribe to a topic and the message lands in a variable, ready for the rest of your flow. Wildcards let one subscription cover many devices or zones.

MQTT Subscribe block
MQTT Subscribegreenhouse/+/vent · QoS 1
Switchmessage
open
Variable Set/Mathvent_open = 1
close
Variable Set/Mathvent_open = 0

Broker settings that installers can change

Link MQTT properties to device settings instead of hard-coding them. The same firmware can then connect to a different broker at each site, configured from the Web Console or the LUIS app.

Linking properties to settings
MQTT Server   ← setting "Broker host"
Port          8883 (TLS)
Client ID     ← setting "Device name"
Username      ← setting "Broker user"
Password      ← setting "Broker password"
Keep Alive    60 s
FAQ

Questions, answered.

Which MQTT brokers can I use?

Any standard MQTT broker. You set the server, port, client ID, username, password, and keep-alive interval.

Is TLS supported?

Yes. Use port 8883 for TLS connections, or 1883 for plain TCP.

Which QoS levels are supported?

QoS 0 (at most once), 1 (at least once), and 2 (exactly once).

Do I need MQTT to use AppBlocks Cloud?

No setup is needed. AppBlocks Cloud uses MQTT under the hood, and connecting to it is a toggle in the Designer. The MQTT client described here is for your own brokers. Explore AppBlocks Cloud.

White-glove onboarding included

Ready to build your first firmware?

Start free in your browser, follow the tutorials, or book a free one-on-one session. No board yet? We’ll demonstrate everything on ours.