Qubitro Documentation
SupportLog inSign Up
  • Documentation
  • Guides
  • Developers
  • Guides
  • Integrations
    • How to Decode Uplink Messages with Qubitro Decoder Functions
    • How to Publish and Decode Multiple Hex Payloads via MQTT on Qubitro
  • Functions & Data Processing
    • How to Use JavaScript for Custom Rule Conditions in Qubitro
    • How to Use JSONata for Real-Time Data Transformation in Qubitro
Powered by GitBook
On this page
  • 🧩 Prerequisites
  • Step 1: Get Your Qubitro MQTT Credentials
  • Step 2: Configure MQTTX (Secure Connection)
  • Step 3: Add Decoder Function in Qubitro
  • Step 4: Publish Multiple Hex Payloads
  • Step 5: View Decoded Data
Export as PDF
  1. Integrations

How to Publish and Decode Multiple Hex Payloads via MQTT on Qubitro

Learn how to publish multiple hex payloads using MQTTX and decode them using Qubitro’s Decoder Function. This guide walks you through secure MQTT setup, payload formatting, and real-time data decoding

PreviousHow to Decode Uplink Messages with Qubitro Decoder FunctionsNextHow to Use JavaScript for Custom Rule Conditions in Qubitro

Last updated 2 months ago

This guide shows how to:

  • ✅ Send multiple hex payloads using MQTTX

  • ✅ Use a custom Qubitro to decode GPS and sensor data

  • ✅ View structured decoded data in the Qubitro portal


🧩 Prerequisites

  • A

  • An existing Device

  • Your device's MQTT credentials


Step 1: Get Your Qubitro MQTT Credentials

  1. Go to your device in the Qubitro Portal

  2. Click the MQTT Credentials tab

  3. Copy:

    • Device ID (used as Username and topic)

    • Device Token (used as Password)

    • Host: broker.qubitro.com

    • Port: 8883 (SSL) or 1883 (non-SSL)

    • Topic: Device ID


Step 2: Configure MQTTX (Secure Connection)

Open MQTTX and configure your connection as shown below:

  • Name: broker.qubitro.com

  • Host: mqtts://broker.qubitro.com

  • Port: 8883

  • Client ID: (same as Device ID)

  • Username: Device ID

  • Password: Device Token

  • SSL/TLS: ✅ Enabled

  • SSL Secure: ✅ Enabled

  • Certificate: CA signed server certificate

Click Connect to establish a secure MQTT connection.


Step 3: Add Decoder Function in Qubitro

1. Go to your device → Functions tab

2. Click Add Function → Choose Decoder Function

3. Paste the following JavaScript code:

function decoder(input) {
  const longitude = ((input.bytes[0] << 24) | (input.bytes[1] << 16) | (input.bytes[2] << 8) | (input.bytes[6] & 0xC0)) /1000000;
  const latitude = ((input.bytes[3] << 24) | (input.bytes[4] << 16) | (input.bytes[5] << 8) | ((input.bytes[6] & 0x30) << 2)) /1000000;
  const hMSL32 = ((((input.bytes[6] & 0x0F) << 8 ) + input.bytes[7]) * 2) - 191;
  const hAccCoeff = (input.bytes[8] & 0xE0) >> 5;
  const vAccCoeff = (input.bytes[8] & 0x1C) >> 2;
  const heading = ((input.bytes[8] & 0x03) << 2) + ((input.bytes[9] & 0xC0) >> 6);
  const speed = (input.bytes[9] & 0x3F);
  const battery = ((input.bytes[10]*256) + input.bytes[11]);
  const year = (input.bytes[12] >> 2) + 2000;
  const month = ((input.bytes[12] & 0x03) << 2) + ((input.bytes[13] & 0xC0) >> 6);
  const day = (input.bytes[13] & 0x3E) >> 1;
  const hour = ((input.bytes[13] & 0x01) << 4) + ((input.bytes[14] & 0xF0) >> 4);
  const minute = ((input.bytes[14] & 0x0F) << 2) + ((input.bytes[15] & 0xC0) >> 6);
  const second = (input.bytes[15] & 0x3F);
  const timestampSeconds = Math.floor(new Date(year, month, day, hour, minute, second).getTime() / 1000);

  return {
    longitude,
    latitude,
    coordinates: [latitude, longitude],
    hMSL32,
    hAccCoeff,
    vAccCoeff,
    heading,
    speed,
    battery,
    time: timestampSeconds
  };
}

You can also test a single hex payload on the Qubitro Portal to verify your decoder.

  1. Save and activate the function.

Step 4: Publish Multiple Hex Payloads

  1. Go to the Publish tab in MQTTX.

  2. In the topic field, paste your Device ID.

  3. Set the payload type to JSON.

  4. Use the following payload:

{
  "payload_hex": "00C08802808560A184000FFB648EAD0F,00c088028085909784000ffb648ead46,00c089028085109284000ffe648ead89,00c088028085e09c84000ffe648eadcb"
}
  1. Click the green send button to publish the message.

Step 5: View Decoded Data

Open the Storage tab in your Qubitro device and you’ll see structured decoded values like:


You’ve successfully:

• Connected MQTTX to Qubitro securely

• Published multiple hex payloads

• Used a custom decoder to parse sensor/GPS values

• Verified decoded output in Qubitro

Qubitro account
MQTTX Desktop App
Decoder Function