> For the complete documentation index, see [llms.txt](https://docs.dataclearinghouse.org/dch-2.0-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dataclearinghouse.org/dch-2.0-documentation/walkthroughs/onboarding-building-data/mqtt.md).

# MQTT

This walkthrough shows a step by step process to onboard building data to DCH using MQTT. This is a general process and does not detail specific gateway/tool workflow. We may have a detailed documentation regarding your gateway, check this [page](/dch-2.0-documentation/si-docs/dch-onboarding-timeseries-data/gateway-instructions.md).

## Step 1: create your sites and buildings on DCH

1. On the sidebar go to **Sites** and click on **Add New Site.**

   <figure><img src="https://2744894366-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9YxMhgYtL3BDmoUdh26N%2Fuploads%2FiBSijjyqLVdyECPCDIqO%2Fimage.png?alt=media&amp;token=b211bc78-6579-4ffc-802c-663b374081e5" alt=""><figcaption></figcaption></figure>
2. Enter a **Site ID**. All other fields including the address details are optional.

   <figure><img src="https://2744894366-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9YxMhgYtL3BDmoUdh26N%2Fuploads%2FJ8UYKX6DhBKKsbDQQYJx%2Fimage.png?alt=media&amp;token=a063a1b0-c229-419b-94c3-e9c721bb15a3" alt=""><figcaption></figcaption></figure>
3. Press **Create Site Information.**
4. On the sidebar, go to **Sites** again and press on **Add New Building.**
5. Select your previously created site and set a **Building ID**. All other fields are optional.

   <figure><img src="https://2744894366-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9YxMhgYtL3BDmoUdh26N%2Fuploads%2F0eAOsFos3WpiKfudnGeI%2Fimage.png?alt=media&amp;token=92b11367-e32e-4ae1-9ce1-c26fcb97e097" alt=""><figcaption></figcaption></figure>
6. Press **Create Building Information**

You now have a site and that site has a building.

## Step 2: create a data source for your site/building

A detailed description of this step is provided [here](/dch-2.0-documentation/data-management/adding-a-new-data-source.md). At the end of this step you should have:

1. Your MQTT username
2. Your MQTT password

In this case, our username is **dsapi-annoying-willing-tank:<a34960ca-5f96-477f-84df-2015c3efc871@dataclearinghouse.org>** and our password is **walkthrough\_password**.

You can verify your data source is created by navigating to the **Data Sources** page.

<figure><img src="https://2744894366-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9YxMhgYtL3BDmoUdh26N%2Fuploads%2FiIY3m11QpREKrmt43G6t%2Fimage.png?alt=media&amp;token=619f071b-c1ec-4780-92dc-a52dd73d3e0a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2744894366-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9YxMhgYtL3BDmoUdh26N%2Fuploads%2Fo91cCfrl85r4SA2Oe6Qc%2Fimage.png?alt=media&amp;token=bbc2435f-6dde-4f0b-94a7-df748fc6bf83" alt=""><figcaption></figcaption></figure>

## Step 3: publish MQTT messages to the data source

This walkthrough assumes you already have a list of points which you want to export and your gateway is already polling those values. In addition, it assumes your gateway can create JSON payloads and encrypt the data using TLS 1.2. For the purposes of this walkthrough, a simple Python script is publishing mock data to DCH.

The host ID of DCH's broker is **broker.dataclearinghouse.org.**

Please make sure you have read [this section](/dch-2.0-documentation/si-docs/dch-onboarding-timeseries-data/building-to-dch-data-export-process.md#payload-schema) of the documentation before you continue. For this walkthrough we will be using the full recommended payload. The topic of all MQTT messages will be:

```json
dch/walkthrough_site/walkthrough_building/generic/walkthrough_datasource
```

{% hint style="info" %}
Consistency between your site/building IDs on DCH and your MQTT messages is incredibly helpful and will be handy for the BRICK model construction later.
{% endhint %}

A sample payload would be:

```json
{
    "$schema": "http://csiro.au/dch/bms-json/schema-draft-07.json",
    "point": {
        "pointName": "Air_Temp",
        "timestamp": "2024-03-04T12:03:26.993+11:00",
        "currentValue": 15.822375150773174,
        "parentName": "W_First_Floor_Room_1",
        "facets": {
            "units": "degrees celsius"
        }
    }
}
```

{% hint style="info" %}
To summarise:

* Host ID: broker.dataclearinghouse.org
* Port: tcp\_8883
* Encryption: TLS 1.2
* Username: dsapi-annoying-willing-tank:<a34960ca-5f96-477f-84df-2015c3efc871@dataclearinghouse.org>
* Password: walkthrough\_password
* MQTT topic:  dch/walkthrough\_site/walkthrough\_building/generic/walkthrough\_datasource
* Sample MQTT payload:&#x20;

```
{
    "$schema": "http://csiro.au/dch/bms-json/schema-draft-07.json",
    "point": {
        "pointName": "Air_Temp",
        "timestamp": "2024-03-04T12:03:26.993+11:00",
        "currentValue": 15.822375150773174,
        "parentName": "W_First_Floor_Room_1",
        "facets": {
            "units": "degrees celsius"
        }
    }
}
```

{% endhint %}

If the publish is successful, you should be able to see the data on DCH. Navigate to your data source again and the points should be listed there after a short period of time.

<figure><img src="https://2744894366-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9YxMhgYtL3BDmoUdh26N%2Fuploads%2FxFiwU1AA8yaifMy0B0FC%2Fimage.png?alt=media&amp;token=27f0708c-edd4-4283-8e34-21ce53451640" alt=""><figcaption></figcaption></figure>
