> For the complete documentation index, see [llms.txt](https://freegrow-1.gitbook.io/product-docs-en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://freegrow-1.gitbook.io/product-docs-en/en-creator-kit-q1/uwb-creator-kit-q1-complete-setup-and-usage-guide/advanced-guide-for-gateway/building-your-own-server.md).

# Building Your Own Server

### &#x20;In This Guide

This guide explains how to use **MQTT-Studio** to connect to the **Mosquitto broker** and subscribe to the real-time UWB location data sent from the GrowSpace Gateway.\
\
When you want to integrate the tag and anchor location data with a server or cloud system via the MQTT broker, setting up the MQTT subscription environment as described in this guide will make the data integration process much easier.

> ⚠️ If you are setting up or configuring the **MQTT server (Mosquitto broker)** for the first time, please refer to the document below to prepare your server environment.\
> [<mark style="color:$primary;">**Go to the MQTT Server Setup Guide**</mark>](https://freegrow-1.gitbook.io/product-docs-en/en-creator-kit-q1/undefined/mqtt)

However, even before setting up the server,\
you can configure a test environment using **MQTT-Studio**. We recommend following the steps in this guide to learn the process of connecting to the broker and subscribing to data. This will help you familiarize yourself with the steps before the server setup.

***

### Creating a Project in MQTT-Studio

#### Creating a Project

* Open **MQTT-Studio**.
* In the left menu, click **New Project**.

<figure><img src="/files/yYbiwUA2b2HgZjaHJPPh" alt=""><figcaption></figcaption></figure>

* Enter the following details:

| Item                    | Description                                                                             |
| ----------------------- | --------------------------------------------------------------------------------------- |
| **Project name**        | **Project name** (e.g. `growspace-test`)                                                |
| **MQTT Broker**         | **IP address** of the PC where the **Mosquitto broker** is installed                    |
| **Port**                | Keep the default port **`1883`**                                                        |
| **Client ID**           | Enter a unique, random name (e.g. `testclient1`)                                        |
| **Username / Password** | Enter settings according to the broker configuration, or leave it blank if not required |

> If connecting within the same network, simply enter the **IP address** to establish the connection.
>
> For external connections, you will need to configure **port forwarding** on the router for **port 1883.**

<figure><img src="/files/cCIFF9XCFiYBgF61NKJn" alt=""><figcaption></figcaption></figure>

* Once the connection is successfully established, the status in the top right corner will change to **CONNECT**.

<figure><img src="/files/8bNgsZTtLPeLf1N8nkzZ" alt=""><figcaption></figcaption></figure>

***

#### How to Check the IP Address (Windows)

* Type `cmd` in the Windows search bar and open the **Command Prompt**.
  * Enter the command `ipconfig` and press **Enter**.

<figure><img src="/files/GM3x0AydWQxy5Y3h8XjP" alt="" width="563"><figcaption></figcaption></figure>

* In the output, locate the **`IPv4 Address`** field.\
  Example: `192.168.0.101`

<figure><img src="/files/u8o75mtMz4fn3hXp9hh9" alt="" width="563"><figcaption></figcaption></figure>

&#x20;       \* Use this address(주소) as the IP for the **MQTT Broker**.

***

### Configuring Gateway Data Subscription

After connecting to the Mosquitto broker, subscribe to the topics in **MQTT-Studio** to receive location data.

* Click the **+** button in the top-right corner.
* Enter and add the following 3 topics:

| Topic                   | Description                                                          |
| ----------------------- | -------------------------------------------------------------------- |
| `uwb/gateway/start/#`   | Gateway Boot Status Information                                      |
| `uwb/gateway/config/#`  | **Configuration data**, including settings and measurement intervals |
| `uwb/gateway/devices/#` | **Real-time location data** of tags and anchors                      |

> The **`#`** symbol subscribes to all subtopics within the specified path.\
> The **`projectId`** included in the topic structure is configured based on the **API key** issued on the GrowSpace Web Configuration page.

<figure><img src="/files/lrah7RiRsEgpNhBlXq5E" alt=""><figcaption></figcaption></figure>

***

### Saving the Project

Once the topics are registered, click **Save Project** in the top-left menu to save the configuration.\
You can later quickly reconnect with the same settings by selecting **Open Project**.

***

### Gateway Configuration and Data Transmission

Through the **GrowSpace Web Configuration Page**, you can configure the **GrowSpace Gateway Q1** device to send data to a private **Mosquitto broker**.

#### Configuration Steps

* Connect the power to the gateway.

<figure><img src="/files/MoK1mzJTqPZI7pbVIMvm" alt=""><figcaption></figcaption></figure>

* Open **Google Chrome** and navigate to the following web page.\
  <https://uwb-gateway.web.app>
* From the top menu of the page, go to the **Gateway Settings** section.
* Enter the required details in the fields below.

| Item                      | Description                                                                    |
| ------------------------- | ------------------------------------------------------------------------------ |
| **Wi-Fi Name / Password** | Enter the **2.4GHz Wi-Fi** information (5GHz is not supported)                 |
| **MQTT IP**               | Enter the **IP address** of the PC where the **Mosquitto broker** is installed |

<figure><img src="/files/IKZLCdktFgd2VO46ZpIk" alt=""><figcaption></figcaption></figure>

* After filling in all the fields, click **Save**. The gateway will automatically restart and begin sending data to the configured MQTT broker.

***

### Confirm Data Reception in MQTT-Studio

Once the gateway configuration is complete, real-time location data will begin to appear automatically in **MQTT-Studio**. Below is an example of the actual received message.

```
Topic: uwb/gateway/devices/project-1234/TAG-001
{
  "tagId": "TAG-001",
  "x": 12.34,
  "y": 56.78,
  "z": 1.23,
  "timestamp": 1723850283
}
```

Using this data, you can check the tag’s location or integrate it with a real-time monitoring system.

<figure><img src="/files/n568pLwpFARU26THYZvT" alt=""><figcaption></figcaption></figure>
