> For the complete documentation index, see [llms.txt](https://docs.yudash.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yudash.com/pf/ct/mqtt.md).

# MQTT

MQTT is a lightweight publish/subscribe protocol widely used for IoT telemetry.

In a typical YuDash installation, the **YuDash device acts as an MQTT client and publisher**. It connects to an MQTT broker and publishes the configured payload to a topic. The broker then makes that data available to the receiving IoT platform or other subscribed MQTT clients.

### MQTT Example

In this example, a YuDash FELYX device will publish two telemetry variables:

* **Temperature**
* **Humidity**

These variables may be acquired from any configured sensor interface, such as **Modbus, analog inputs, or another supported source**. Once available inside the device, they are encoded into a JSON payload and published over MQTT.

For this example, **ThingsBoard Cloud** is used as the receiving IoT platform and MQTT broker.

The target telemetry payload is:

```
{
  "Temperature": 29.01,
  "Humidity": 67.39
}
```

The complete flow is:

```mermaid
flowchart LR
    A["Temperature / Humidity"] --> B["YuDash FELYX"]
    B --> C["JSON_FORMAT_10"]
    C --> D["ThingsBoard MQTT Broker"]
```

#### Step 1 — Open the MQTT Wizard

From **Cloud Settings**, select **Open MQTT Wizard**.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FHtCsYRjH4tOAiBcQmJZL%2F01_mqtt_open_wizard.png?alt=media&amp;token=a203afc7-57b3-46f8-9cdc-decf16d4b13e" alt=""><figcaption></figcaption></figure>

***

#### Step 2 — Configure Broker & Topics

Enter the connection details supplied by the MQTT broker or IoT platform.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FhAlavFwpabR9TFosLeM8%2F02_mqtt_broker_topics.png?alt=media&amp;token=c3b262b1-706d-4c4f-b2c5-7c0e8f7076e9" alt=""><figcaption></figcaption></figure>

For the ThingsBoard example:

| Setting             | Example                    | Description                                          |
| ------------------- | -------------------------- | ---------------------------------------------------- |
| **Broker Host**     | `mqtt.thingsboard.cloud`   | MQTT broker hostname or IP address                   |
| **Port**            | `1883`                     | MQTT broker port                                     |
| **Client ID**       | `YuDash_FELYX`             | Client identifier used by the YuDash device          |
| **Username**        | `<ACCESS_TOKEN>`           | Username or access token required by the broker      |
| **Password**        | blank                      | Password, where required                             |
| **Publish Topic**   | `/v1/devices/me/telemetry` | Topic to which telemetry is published                |
| **Subscribe Topic** | optional                   | Topic used where incoming MQTT messages are required |
| **YuDM Topic**      | optional                   | Reserved for YuDash device-management applications   |

The current FELYX configuration stores the broker address, port, client name, username, password and publish topic as MQTT settings. mqtt\_thingsboard

> Broker authentication varies between platforms. Some brokers use a username and password, while others use an access token or allow unauthenticated connections.

#### Step 3 — Select MQTT as the Cloud Protocol

Under **Device Settings → Cloud / Network Server**, select:

**Custom Protocol → MQTT**

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FFY2w1aCpeUI9A8YOYj3u%2F03_mqtt_select_protocol.png?alt=media&amp;token=0d53ae11-f941-43dd-a480-2f3cf49cd71c" alt=""><figcaption></figcaption></figure>

#### Step 4 — Configure the Payload

MQTT defines **how the data is transported**; the Payload settings define **what data is published**.

For this example, **`JSON_FORMAT_10`** is used to generate a simple JSON key-value payload.

The target payload is:

```
{
  "Temperature": 29.01,
  "Humidity": 67.39
}
```

Each acquired variable is sent directly as a JSON key-value pair. This is a simple and widely compatible format for MQTT telemetry.

Payload format, timestamp and optional metadata are configured separately under **Cloud Telemetry → Payload**.

### Step 5 — Verify MQTT Telemetry

Once configured, FELYX periodically acquires the configured sensor values, generates the payload and publishes it to the MQTT broker.

In this example, FELYX acquires **Temperature** and **Humidity** as the telemetry variables.

#### Verify with an MQTT Subscriber

An independent MQTT client such as **MQTTX** can also be used to subscribe to a topic and verify the messages available through the MQTT broker.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FLw5u1DsuR2DlQU9VeZVW%2F05_mqttx_received_payload.png?alt=media&amp;token=80b755bd-496a-4daa-bd16-0db179420c2f" alt=""><figcaption></figcaption></figure>

This is useful during commissioning because it allows the transmitted MQTT payload to be inspected independently of the final IoT application.

> MQTTX is shown here only as an example MQTT subscriber. Any compatible MQTT client may be used.

#### Verify in ThingsBoard

The latest values received by ThingsBoard can be viewed under the device's **Latest telemetry** section.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FBvr5v8qtjS3tuUUTjnDW%2F04_mqtt_thingsboard_latest_telemetry.png?alt=media&amp;token=3b4c374e-c86b-4990-b613-6eaa6149590b" alt=""><figcaption></figcaption></figure>

The received values confirm the complete telemetry path:

**Sensor → FELYX → MQTT Broker → ThingsBoard**

If required, the stored telemetry can also be viewed as a time series.

<figure><img src="https://1858257737-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FToww5EM1cml3ouN6fvnJ%2Fuploads%2FtOEN2eCT9f1ooxjY9Ns0%2F06_mqtt_thingsboard_timeseries_optional.png?alt=media&amp;token=ad349e63-b5d2-4dee-bc2b-04a5214e8419" alt=""><figcaption></figcaption></figure>

####

### MQTT Publish Command Equivalent

Conceptually, the YuDash MQTT client performs the same operation as an MQTT publish command: it connects to the configured broker and publishes a payload to the configured topic.

For example:

```
mosquitto_pub \
  -h mqtt.thingsboard.cloud \
  -p 1883 \
  -t v1/devices/me/telemetry \
  -u "<ACCESS_TOKEN>" \
  -m '{"temperature":25}'
```

The corresponding relationship is:

| YuDash MQTT Setting     | `mosquitto_pub` option |
| ----------------------- | ---------------------- |
| Broker Host             | `-h`                   |
| Port                    | `-p`                   |
| Client ID               | `-i`                   |
| Username / Access Token | `-u`                   |
| Password                | `-P`                   |
| Publish Topic           | `-t`                   |
| Generated Payload       | `-m`                   |

The supplied ThingsBoard test uses the same broker, port, publish topic and access-token-style username. thingsboard\_mosquito

> **In simple terms, FELYX acts as an automated MQTT publisher:** it continuously acquires sensor data, generates the configured payload and publishes it to the configured MQTT broker.
