# MQTT Server Installation and Setup

### In This Guide

we explain how to connect the **GrowSpace Gateway Q1** to a **private MQTT broker (Mosquitto)** to receive real-time location data from tags and anchors, and how to visualize that data using **MQTT-Explorer** or **MQTT-Studio**.

By default, the gateway connects to the **FreeGROW server**, but for internal testing or integration with external systems, you can easily set up a local environment using Mosquitto.

***

### What Is Mosquitto?

**Mosquitto** is an open-source message broker that uses the **MQTT (Message Queuing Telemetry Transport)** protocol.

MQTT is a lightweight messaging protocol widely used in IoT (Internet of Things) environments. It allows efficient real-time communication between devices.

Key features of Mosquitto include:

* Easy to install, lightweight, and simple to configure
* Supports stable connections for hundreds or even thousands of devices
* Runs over TCP/IP and supports authentication and encryption

Since the **GrowSpace Gateway Q1** uses the MQTT protocol to transmit data, you can use **Mosquitto** to receive and process location data on your own local server—without relying on a cloud connection.

***

### Installing and Configuring the Mosquitto Broker

#### Install Mosquitto

* Download the Windows installer from the [official Mosquitto website](https://mosquitto.org/download/)

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

* Install it using the default installation path:

```
C:\Program Files\mosquitto
```

#### Edit the Configuration File

* Open the configuration file using Notepad or VS Code. You can find it at the following path:

```
C:\Program Files\mosquitto\mosquitto.conf
```

* Add the following lines under the corresponding settings:
  * Search for the `listener` section, then add the line **below** it:

    ```
    listener 1883 0.0.0.0
    ```
  * Search for the `allow_anonymous` section, then add the line **below** it:

    ```
    allow_anonymous true
    ```

> 🔸 The `listener` setting specifies the port used to allow external devices to connect.\
> 🔸 `allow_anonymous true` allows connections without requiring user authentication.

{% hint style="info" %}
Leave the original lines `#listener` and `#allow_anonymous false` commented out.\
Only the two new lines you added will be applied.
{% endhint %}

* After saving the file, **restart Mosquitto** or **reboot your PC**.

This configuration allows external devices (such as the GrowSpace Gateway) to connect to the Mosquitto broker.

### Allow Port Through Windows Firewall

To enable the Mosquitto broker to communicate with external devices (such as the GrowSpace Gateway), you must allow **TCP port 1883** through the firewall.\
\
Follow the steps below to add a new inbound rule:

#### How to Add a Firewall Rule

{% stepper %}
{% step %}
Click the **Start** button, type **"firewall"**, and open **Windows Defender Firewall**

<figure><img src="/spaces/YKyrLLe7cm7ZOhiSB0gg/files/c3gZb2B4BwHPXQ10WGZc" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
In the left menu, click **Advanced settings**

<figure><img src="/files/MAgbQCnW1Dt8sMI81kEl" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
In the left panel, select **Inbound Rules**, then click **New Rule** on the right

<figure><img src="/files/da0FYffjW5j5PwX84KM4" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
For rule type, select **Port** → Click **Next**

<figure><img src="/files/kNrKCQpqTB9N7hnQSemj" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Protocol and Ports**:

Protocol: `TCP`\
Specific local port: `1883` → Click Next

<figure><img src="/files/zral5UMrhlwhhAVOHvKW" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Action

Select **`Allow the connection`** → Click **Next**

<figure><img src="/files/ozq8lxA6q3wqbL3JCC6N" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Profile

Check all three: **Domain**, **Private**, and **Public** → Click **Next**

<figure><img src="/files/tEUqzYRihSRG3s7T8sLV" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Name

Enter a name like Allow **`Mosquitto MQTT`** → Click **Finish**

<figure><img src="/files/OsRO2bc1s3VapyuiZnrN" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Once done, **restart your computer** to apply the changes.
{% endstep %}
{% endstepper %}

> If the port is not properly opened, the gateway will not be able to send data to the MQTT broker.\
> If you have connection issues during testing, please double-check your firewall settings.

***

### Installing MQTT-Studio and Connecting to the Broker

#### Why use this tool?

**`MQTT-Studio`** is a visualization tool that lets you connect to the **Mosquitto broker** and monitor whether location data is being transmitted correctly in real time.

* Instantly view MQTT messages sent from the gateway
* Easily check `Start`, `Config`, and `Devices` data by topic
* Useful for **development, debugging, and live demos**

### Installation Steps

{% stepper %}
{% step %}
Open the **Microsoft Store** from the Windows taskbar

<figure><img src="/files/Y5EtTnpO4sUQozSCbvRc" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Type **`"MQTT-Studio"`** in the search bar

<figure><img src="/files/MZDx1avqrc5uQOejK6KC" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Select **MQTT-Studio** from the list and click **\[Install]**
{% endstep %}

{% step %}
Once the installation is complete, launch the program
{% endstep %}
{% endstepper %}

#### Broker Connection Setup

After launching **MQTT-Studio**, click the **\[New Project]** button in the left menu.\
Enter the following information:

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

| Item                | Description                                                                                           |
| ------------------- | ----------------------------------------------------------------------------------------------------- |
| Project name        | Enter a name of your choice (e.g., `growspace-test`)                                                  |
| MQTT Broker         | IP address of the PC where Mosquitto is installed (Check via Windows CMD → `ipconfig` → IPv4 Address) |
| Port                | Port: `1883` (leave as default)                                                                       |
| Client ID           | A unique client ID (e.g., `testclient1`)                                                              |
| Username / Password | Leave other fields blank if no additional settings are required                                       |

If you're on the **same router (local network)**, you can connect by simply entering the **IP address**.

To connect from an **external network (internet)**, you need to set up **port forwarding** on the router of the PC where the broker is installed: Forward **TCP port 1883** to the PC's **local IP address**.

#### Connection Check

After entering all the required fields, click the **\[Connect]** button.\
If the connection is successful, the **CONNECT** indicator at the top of the screen will become active.

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

***

### Setup Complete

You have now installed the Mosquitto broker, configured the necessary port settings, and successfully visualized data using MQTT-Studio. With this setup, you can receive **UWB location data** from the **GrowSpace Gateway Q1** through your own local broker.

In the next step, you will configure the gateway device and start transmitting real location data.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://freegrow-1.gitbook.io/product-docs-en/en-creator-kit-q1/learn-more/mqtt-server-installation-and-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
