---
id: mqtt
title: 1.2 MQTT Settings
sidebar_label: 1.2 MQTT
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

:::note
This is still under development, use at your own risk. Report any bugs you see by creating an issue on the [meshtastic/Meshtastic-device](https://github.com/meshtastic/Meshtastic-device) repository or comment on our forum.
:::

:::caution
You may want to change your [GPS location sharing settings](gps#location_share) if you are enabling this. It will broadcast your location over the internet.
:::

## Overview

If your device is connected to WiFi you can enable it to forward messages along to an MQTT server. This allows users on the local mesh to communicate with users on the internet.

## Settings

|         Setting         | Acceptable Values | Default |
| :---------------------: | :---------------: | :-----: |
|    downlink_enabled     |  `true`, `false`  | `false` |
|      mqtt_disabled      |  `true`, `false`  | `false` |
| mqtt_encryption_enabled |  `true`, `false`  | `false` |
|      mqtt_password      |     `string`      |  `""`   |
|       mqtt_server       |     `string`      |  `""`   |
|      mqtt_username      |     `string`      |  `""`   |
|     uplink_enabled      |  `true`, `false`  | `false` |

### downlink_enabled

This is a channel specific setting. If your channel has this set to `true` and you are connected to WiFi, the device will forward along messages from the MQTT server specified [here](#mqtt_server) to the mesh from this device.

#### Enable/Disable downlink_enabled

<Tabs
groupId="settings"
defaultValue="cli"
values={[
{label: 'CLI', value: 'cli'},
{label: 'Android', value: 'android'},
{label: 'iOS', value: 'iOS'},
{label: 'Web', value: 'web'},
]}>
<TabItem value="cli">

```shell title="Enable downlink_enabled on PRIMARY channel"
meshtastic --ch-set downlink_enabled true --ch-index 0
```

```shell title="Disable downlink_enabled on PRIMARY channel"
meshtastic --ch-set downlink_enabled false --ch-index 0
```

```shell title="Enable downlink_enabled on OTHER channel"
meshtastic --ch-set downlink_enabled true --ch-index 1
```

```shell title="Disable downlink_enabled on OTHER channel"
meshtastic --ch-set downlink_enabled false --ch-index 1
```

  </TabItem>
  <TabItem value="android">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="iOS">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="web">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
</Tabs>

### mqtt_disabled

If a meshtastic node is able to reach the internet it will normally attempt to gateway any channels that are marked as `uplink_enabled` or `downlink_enabled`. But if this flag is set, all MQTT features will be disabled and no servers will be contacted.

#### Enable/Disable MQTT

<Tabs
groupId="settings"
defaultValue="cli"
values={[
{label: 'CLI', value: 'cli'},
{label: 'Android', value: 'android'},
{label: 'iOS', value: 'iOS'},
{label: 'Web', value: 'web'},
]}>
<TabItem value="cli">

```shell title="Enable MQTT (Default)"
meshtastic --set mqtt_disabled false
```

```shell title="Disable MQTT"
meshtastic --set mqtt_disabled true
```

  </TabItem>
  <TabItem value="android">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="iOS">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="web">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
</Tabs>

### mqtt_encryption_enabled

Determines whether or not the device sends the packets encrypted to/from your MQTT server.

:::tip
If you are using the default Meshtastic MQTT server, this setting will take no effect. All packets will continue to be encrypted regardless of this setting. Only custom servers will honor this setting.
:::

#### Enable/Disable MQTT Encryption

<Tabs
groupId="settings"
defaultValue="cli"
values={[
{label: 'CLI', value: 'cli'},
{label: 'Android', value: 'android'},
{label: 'iOS', value: 'iOS'},
{label: 'Web', value: 'web'},
]}>
<TabItem value="cli">

```shell title="Publish decrypted packets to MQTT (Default)"
meshtastic --set mqtt_encryption_enabled false
```

```shell title="Publish encrypted packets to MQTT"
meshtastic --set mqtt_encryption_enabled true
```

  </TabItem>
  <TabItem value="android">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="iOS">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="web">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
</Tabs>

### mqtt_password

MQTT password to use (most useful for a custom MQTT server). If using a custom server, this will be honoured even if empty. If using the default server, this will only be honoured if set, otherwise the device will use the default password `large4cats`.

#### Configure mqtt_password

<Tabs
groupId="settings"
defaultValue="cli"
values={[
{label: 'CLI', value: 'cli'},
{label: 'Android', value: 'android'},
{label: 'iOS', value: 'iOS'},
{label: 'Web', value: 'web'},
]}>
<TabItem value="cli">

```shell title="Set mqtt_password"
meshtastic --set mqtt_password mypassword
```

```shell title="Set mqtt_password (with spaces)"
meshtastic --set mqtt_password "my password"
```

```shell title="Unset mqtt_password (Default)"
meshtastic --set mqtt_password ""
```

  </TabItem>
  <TabItem value="android">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="iOS">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="web">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
</Tabs>

### mqtt_server

The server to use for our MQTT global message gateway feature. If not set, the default server will be used

#### Enable/Disable MQTT Server

<Tabs
groupId="settings"
defaultValue="cli"
values={[
{label: 'CLI', value: 'cli'},
{label: 'Android', value: 'android'},
{label: 'iOS', value: 'iOS'},
{label: 'Web', value: 'web'},
]}>
<TabItem value="cli">

:::tip
When the mqtt_server is set to `""`, it will default to `mqtt.meshtastic.org`
:::

```shell title="Enable MQTT Server - Public Meshtastic MQTT Server (Default)"
meshtastic --set mqtt_server ""
```

```shell title="Enable MQTT Server - Personal MQTT Server (by IP)"
meshtastic --set mqtt_server 198.168.0.2
```

```shell title="Enable MQTT Server - Personal MQTT Server (by URL)"
meshtastic --set mqtt_server mqtt.mydomain.com
```

  </TabItem>
  <TabItem value="android">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="iOS">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="web">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
</Tabs>

### mqtt_username

MQTT username to use (most useful for a custom MQTT server). If using a custom server, this will be honoured even if empty. If using the default server, this will only be honoured if set, otherwise the device will use the default username `meshdev`.

#### Configure mqtt_username

<Tabs
groupId="settings"
defaultValue="cli"
values={[
{label: 'CLI', value: 'cli'},
{label: 'Android', value: 'android'},
{label: 'iOS', value: 'iOS'},
{label: 'Web', value: 'web'},
]}>
<TabItem value="cli">

```shell title="Set mqtt_username"
meshtastic --set mqtt_username myusername
```

```shell title="Set mqtt_username (with spaces)"
meshtastic --set mqtt_username "my username"
```

```shell title="Unset mqtt_username (Default)"
meshtastic --set mqtt_username ""
```

  </TabItem>
  <TabItem value="android">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="iOS">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="web">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
</Tabs>

### uplink_enabled

This is a channel specific setting. If your channel has this set to `true` and you are connected to WiFi, the device will forward along messages to whatever MQTT server is specified in [mqtt_server](#mqtt_server).

#### Enable/Disable uplink_enabled

<Tabs
groupId="settings"
defaultValue="cli"
values={[
{label: 'CLI', value: 'cli'},
{label: 'Android', value: 'android'},
{label: 'iOS', value: 'iOS'},
{label: 'Web', value: 'web'},
]}>
<TabItem value="cli">

```shell title="Enable uplink_enabled on PRIMARY channel"
meshtastic --ch-set uplink_enabled true --ch-index 0
```

```shell title="Disable uplink_enabled on PRIMARY channel"
meshtastic --ch-set uplink_enabled false --ch-index 0
```

```shell title="Enable uplink_enabled on OTHER channel"
meshtastic --ch-set uplink_enabled true --ch-index 1
```

```shell title="Disable uplink_enabled on OTHER channel"
meshtastic --ch-set uplink_enabled false --ch-index 1
```

  </TabItem>
  <TabItem value="android">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="iOS">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="web">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
</Tabs>

## Details

<!--- TODO --->

## Examples

<Tabs
groupId="settings"
defaultValue="cli"
values={[
{label: 'CLI', value: 'cli'},
{label: 'Android', value: 'android'},
{label: 'iOS', value: 'iOS'},
{label: 'Web', value: 'web'},
]}>
<TabItem value="cli">

```shell title="Set server"
meshtastic --set mqtt_server 192.168.123.234
```

```shell title="Enable MQTT server to mesh"
meshtastic --ch-set uplink_enabled true --ch-set downlink_enabled true --ch-index 0
```

```shell title="View raw encoded messages using mosquitto"
mosquitto_sub -h 192.168.123.234 -v -t msh/#
```

:::note
FIXME some documentation says msh/# , some says mesh/# . As of 1.2.39 the messages are on msh/#
:::

</TabItem>
<TabItem value="android">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="iOS">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
  <TabItem value="web">

:::info
Configuring this setting is not yet available for the selected platform. If this is incorrect please update the documentation for this page.
:::

  </TabItem>
</Tabs>