# Sending values to MQTT

In this example we'll configure Clarity Gateway to send the value of an Iron Pi analog input to an MQTT connection.

## Bulk mapping via the channels table

In the page for your MQTT connection, scroll down to the **Channels To MQTT** section. Click the **Show All Tags** switch if it is not already on:

![](https://1557066017-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSPy42kVbNL57hubF20gF%2Fuploads%2Fgit-blob-dba8743baff41ed33356c51a9f4a7c9c75401c91%2Flocalhost_50000_network%20\(15\).png?alt=media)

All system tags in Clarity Gateway will then appear in the table. In this example we'll be mapping Local I/O channel 1, which is configured as an analog input and mapped to the system tag **channel1**:

![](https://1557066017-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSPy42kVbNL57hubF20gF%2Fuploads%2Fgit-blob-7b7dbda53153e5c808f376322d0a4539c2e6ac5e%2Flocalhost_50000_network%20\(16\).png?alt=media)

First check the **Enabled** checkbox to enable this mapping:

![](https://1557066017-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSPy42kVbNL57hubF20gF%2Fuploads%2Fgit-blob-9529fb46d7365c78be592d5b4ca5b9d8e5d378fa%2Flocalhost_50000_network%20\(18\).png?alt=media)

Then enter the **MQTT Tag** to send values to. In this example we'll use **localio/channel1:**

![](https://1557066017-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSPy42kVbNL57hubF20gF%2Fuploads%2Fgit-blob-33f0ac242784e7ee4c8c559c682a590fadcd7938%2Flocalhost_50000_network%20\(19\).png?alt=media)

Finally, click **Save:**

![](https://1557066017-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSPy42kVbNL57hubF20gF%2Fuploads%2Fgit-blob-96aa0392d0d2e45f8d81e1f87834d43ee555cfd1%2Flocalhost_50000_connections_8.png?alt=media)

Once the mapping is applied, the arrow should change color from gray to blue to indicate that the mapping is active:

![](https://1557066017-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSPy42kVbNL57hubF20gF%2Fuploads%2Fgit-blob-418096e5ee0ecc360a635c4c239632116c019827%2Flocalhost_50000_connections_8%20\(1\).png?alt=media)

## Advanced mapping

For more options when mapping a channel, click the `+` icon in the **Channels To MQTT** section:

![](https://1557066017-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSPy42kVbNL57hubF20gF%2Fuploads%2Fgit-blob-7029b599fae96cfe7a1161e608619bbb47a0080a%2Flocalhost_50000_connections_8%20\(3\).png?alt=media)

This will take you to a separate **Create Channel** page. In that page, first enter the Clarity Gateway **System Tag** you would like to send to MQTT. In this example, we'll be using **channel1**, which is configured as a Local I/O analog input:

![](https://1557066017-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSPy42kVbNL57hubF20gF%2Fuploads%2Fgit-blob-ce870eb97415f70f30319f711956b6f3793c67fe%2Flocalhost_50000_connections_8%20\(4\).png?alt=media)

Optionally, you can enter a **Slope** and **Offset** to transform the values that get sent to MQTT. In this example we will enter **2** and **3**:

![](https://1557066017-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSPy42kVbNL57hubF20gF%2Fuploads%2Fgit-blob-ead1239836ca856935e35c7d5f182045523a4058%2Flocalhost_50000_connections_8%20\(6\).png?alt=media)

Finally, enter the **MQTT Tag** to send to and **Data Type** to use. In this example, we'll send values to **localio/channel1** as **Float**s:

![](https://1557066017-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSPy42kVbNL57hubF20gF%2Fuploads%2Fgit-blob-86420dbe6a98f48dfc010bdaa51dc13b46d36b4c%2Flocalhost_50000_connections_8%20\(7\).png?alt=media)

Finally, click **Save** to create the channel:

![](https://1557066017-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSPy42kVbNL57hubF20gF%2Fuploads%2Fgit-blob-5a9d55f05b336e569cb45e70e517681f5b034edf%2Flocalhost_50000_connections_8%20\(8\).png?alt=media)

Once the channel has been created, you will return to the connection page. The new channel should appear in the **Channels To MQTT** table. Notice how the system value is 9.68, and the value sent to MQTT is 2 \* 9.68 + 3 = 22.2:

![](https://1557066017-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSPy42kVbNL57hubF20gF%2Fuploads%2Fgit-blob-3b1377dd87d66b026f4c57c26870115810b7cd66%2Flocalhost_50000_connections_8%20\(11\).png?alt=media)
