# MQTT Publish Format V1

{% hint style="success" %}
**Best for Edge to Cloud transfers**
{% endhint %}

Posting Data to AlphaX is a relatively simple process. The user must format his/her data in the correct format and simply publish it to the AlphaX Cloud MQTT service. The AlphaX system will automatically take care of the rest!

{% hint style="info" %}
NOTE: The user must first enable Conduit using his/her user profile. Follow this article here for help: [**https://minnovation.com.au/knowledge-base/how-to-enable-conduit-for-a-user/**](https://minnovation.com.au/knowledge-base/how-to-enable-conduit-for-a-user/)
{% endhint %}

The user must also enable the MQTT checkbox on the Conduit feature.

The user can now Subscribe/Publish to the the MQTT service at mqtt.alphax.cloud using the credentials provided.

### Publish Topic V1:

\<token>/\<device id>/pub/v1

**token \[REQUIRED]:** The unique security token for each user. This is available from the User window in AlphaX. This parameter is required to access the conduit service, if confused about how to get token, please contact the Minnovation Team.

**device id** **\[REQUIRED]**: The unique network ID that is used to register and track the device in the AlphaX system. This parameter is mandatory, if not defined, you will receive an error message.

### Publish Message V1

**payload\[REQUIRED]:** The byte array that contains the data for the publish. The data must assume the standard data format for AlphaX as documented here: <https://minnovation.com.au/knowledge-base/payload/>

#### Formatting the Data Object

In a V1 n-byte payload, the first 8 bytes are mandatory and always corresponds to device level data. Any bytes after these mandatory bytes corresponds to individual channel data.

The data object should be formatted as a byte array using the following structure.

data: 0A10010001000000A00FA00F0000

#### Mandatory Data (Device Data)

Device data is mandatory when using the v1 packet format. This data refers to the first 8 bytes of data in the bytearray string which are mapped to 4 reserved channels in the AlphaX system when it receives an uplink message.

| Byte Number | Data Type       | Mapped to Channel | Expected units   |
| ----------- | --------------- | ----------------- | ---------------- |
| 1-2         | Device Voltage  | 255               | milliVolts (int) |
| 3-4         | Signal Strength | 254               | RSSI (int)       |
| 5-6         | Message ID      | 253               | Count (int)      |
| 7-8         | Error Code      | 252               | Error ID (int)   |

{% hint style="info" %}
Tip: If the data is not available for the data specified, or should the user wish to pass these values in alternative channels, you can pad any of the listed fields using 0000
{% endhint %}

#### Dynamic Data (Channel Data)

Following the mandatory fields, each channel specific values can be passed as a 4 byte integer. These integers will dynamically fill channels starting at channel 1 up to channel 32 for each 4 byte integer that is added to the end of the packet.

These values are divided by 1000 before being stored in the database to accomodate for floating point precisions.

{% hint style="info" %}
Tip: If more than 3 decimal places are required, we suggest choosing a different data uplink format for ingestion eg. v2 or v3
{% endhint %}

| Byte Number | Data Type     | Mapped to Channel | Expected Units      |
| ----------- | ------------- | ----------------- | ------------------- |
| 9-12        | Channel Value | 1                 | value \* 1000 (int) |
| 13-16       | Channel Value | 2                 | value \* 1000 (int) |
| 17-20       | Channel Value | 3                 | value \* 1000 (int) |
| …           | …             | …                 | …                   |
| 73-76       | Channel Value | 16                | value \* 1000 (int) |

{% hint style="info" %}
Note: AlphaX has a limit of 16 data channels per device. Should additional channels be required, we suggest splitting the data over 2 seperate data sources.
{% endhint %}

### Example Usage

Publish to mqtt.alphax.cloud

#### Topic

```
xxxxxxxxxxxxxxxxxx/mydevice1234/pub/v1
```

#### Message

```
0A10010001000000A00F0000
```

This would submit the data

Fixed Data Channels: 4106 1 1 0

> Being default data of Battery Voltage, Message ID, RSSI and Error Code. If your device doesn’t output these values simply add a 0 to pad the data value out.&#x20;

Dynamic Data Channels: 4000

> Being dynamic data channel of 4000. Note this value is divided by 1000 to convert to a float on storage.

Dynamic channels can be registered in AlphaX using the following link: [**https://minnovation.com.au/knowledge-base/how-to-configure-channel-for-an-alphax-iot-device/**](https://minnovation.com.au/knowledge-base/how-to-configure-channel-for-an-alphax-iot-device/)


---

# 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://apidocs.alphax.cloud/mqtt/publishing-data/mqtt-publish-format-v1.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.
