Network MQTT Client

MQTT client module, to communicate with a MQTT server. The MQTT protocol can be used to retrieve values of sensors on a distant server. See MQTT for more info.

A free broker is available for Usine's users:

broker host = mqtt.brainmodular.com
user = usine
password = usine

Settings

query

Maximum number of topics to publish and maximum number of subscriptions, asked when the module is created (0 to 32 each). The module exposes one topic publish N, payload N, QoS N, retain N group per publication, and one group of outputs (receive N, topic out N, payload string N, payload bytes N) per subscription.

To change them afterwards, recreate the module: the query is asked again and the connections are restored by name.

broker host

Address of the MQTT server (mqtt.brainmodular.com by default).

broker port

Port used for the communication with the server (1883 by default).

client ID

Client identifier used for the communication.

user name

User name of the client, if needed.

password

Password of the client, if needed.

connect

Try to connect the client to the server. See auto connect at startup and auto reconnect parameters below.

disconnect

Try to disconnect the client from the server.

connected

Sends 1 value when the client is connected to the server.

keep alive

Keep alive ensures that the connection between the broker and client is still open and that the broker and the client are aware of being connected.

auto reconnect

Determines the ability for the client to reconnect automatically on connection failure.

auto connect at startup

Connect the client to the server immediately after the module is loaded.

trace data

Traces all incoming data in the trace-panel.

clean session

On connection, a client sets the "clean session" flag, which is sometimes also known as the "clean start" flag. If clean session is set to false, then the connection is treated as durable. This means that when the client disconnects, any subscriptions it has will remain and any subsequent QoS 1 or 2 messages will be stored until it connects again in the future. If clean session is true (the default), then all subscriptions will be removed for the client when it disconnects.

Publishing

topic publish

Topic to publish, as an ASCII string (usine/value1 for the first publication by default).

payload

Payload for the topic as an ASCII string, generally JSON.

QoS

Quality of Service (QoS) level. It is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message. See QoS.

There are 3 QoS levels in MQTT:

  • at most once: level 0.
  • at least once: level 1 (default).
  • exactly once: level 2.

retain

A retained message is a normal MQTT message with the retained flag set to true. The broker stores the last retained message and the corresponding QoS for that topic. See retain.

publish

Publishes all the topics.

Subscription

topics to subscribe

List of all topics to subscribe as a comma-text. ie. "dev/#","sensor/+/temperature".

clear all out

Clears all the subscriptions outputs.

Each received topic gets its own group of outputs: a new topic takes the first free group, a topic already received keeps its group. When all the groups are used, new topics replace the oldest ones in turn.

For example, with topics to subscribe = "sensor/+/temperature", sensor/kitchen/temperature goes to the outputs 1 and sensor/garden/temperature to the outputs 2.

receive

Sends 1 value when a topic is received.

topic out

Topic received as a string.

payload string

Payload received as a string, generally JSON.

payload bytes

Payload received as an array of bytes (ASCII chars).

all receives

Sends 1 value when any of the topics is received. The all outputs give the received messages one by one, one per block, in their order of arrival.

all topics out

All topics received as a string.

all payload strings

All payloads received as a string, generally JSON.

all payloads bytes

All payloads received as an array of bytes (ASCII chars).

Common Settings

info

show manual

Button. Opens the manual page of the selected object (or of its parent module for a control) in the web browser. If no page exists for this object, an error is traced in the trace panel.

For more details about information/help creation, see create-help-file.

description

Free multi-line text attached to the module, saved with the patch. When it is not empty, it is shown as the hint of the module (mouse over the module header in the patch) in place of the default module hint, even when the module hints are disabled.

ID's

visible only in god mode, see setup-panel-tab-expert.

unique ID

Read-only, not saved. Current private numeric ID of the object, used internally to identify it (for example as the target of a bind ID).

preset ID

Read-only, not saved. Private ID used to store and recall the values of this control in presets.

recreate ID

Button. Generates a new unique ID, original ID and preset ID for the object. Use it if you experience difficulties in Polyphonic mode or if two objects share the same ID. Preset values and binds referring to the old IDs are lost.

Object Remote Address

absolute

Read-only, not saved. Absolute address of the object in the Usine objects tree, built from the workspace root. This is the address to use to reach the object from scripts, the objects panel or remote messages. Only shown for objects that are registered in the objects list. See objects-address.

local

Read-only, not saved. Address of the object relative to the current patch, valid inside that patch only. See objects-address.

user addr

Free user-defined address for the object (empty by default). When set, the object is also registered in the objects tree under this name, so it can be reached independently of its position in the workspace (the value is also reported in the mouse-over and mouse-down chunks). Changing it rebuilds the objects list. Only available on objects that support a user address. See objects-address.

See also

version 7.0.250921

Edit All Pages