ThingsBoard Integration

Connect Haltian IoT sensors to ThingsBoard for visualization and analytics
Alpha

ThingsBoard is an open-source IoT platform for data collection, processing, visualization, and device management. This guide shows how to integrate Haltian IoT data with ThingsBoard.

Prerequisites

  • Haltian IoT MQTT credentials (API key ID and token)
  • ThingsBoard instance (Cloud or self-hosted)
  • Device ID mapping (UUID to physical device)

Architecture

%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#F6FAFA', 'primaryTextColor': '#143633', 'primaryBorderColor': '#143633', 'lineColor': '#143633', 'secondaryColor': '#C7FDE6', 'tertiaryColor': '#73F9C1', 'clusterBkg': '#ffffff', 'clusterBorder': '#143633', 'edgeLabelBackground': '#ffffff'}}}%%
graph LR
    A[Haltian Sensors] --> B[Haltian IoT Platform]
    B --> C[MQTT Broker]
    C --> D[ThingsBoard<br/>MQTT Integration]
    D --> E[Uplink Converter]
    E --> F[ThingsBoard<br/>Device Entities]
    F --> G[Dashboards]
    
    style B fill:#143633,stroke:#143633,color:#fff
    style D fill:#73f9c1,stroke:#143633,color:#143633

The uplink converter transforms Haltian IoT MQTT messages into ThingsBoard format.

  1. Navigate to ThingsBoard → Data Converters
  2. Click Add Data ConverterCreate new converter
  3. Set type to Uplink
  4. Paste the following decoder code:
// Haltian IoT MQTT Uplink Converter for ThingsBoard
// Decodes Haltian IoT JSON messages and maps to ThingsBoard telemetry

// Decode payload to JSON
var payloadStr = decodeToString(payload);
var data = decodeToJson(payload);

// Extract device info from MQTT topic
var topic = metadata["topic"];
var topics = topic.split("/");
var deviceName = topics[topics.length - 1];       // Device UUID
var measurementName = topics[topics.length - 2]; // Measurement type

var deviceType = 'Haltian IoT device';
var manufacturer = 'Haltian IoT';

// Build telemetry map
var map = {};

foreach(element : data.entrySet()) {
    var k = element.getKey();
    var v = element.getValue();
    var p = measurementName + "." + k;
    map.put(p, v);
    
    // Special handling for position data
    if (measurementName == "position" && k == "value") {
        if (v.position_global && v.position_global.coordinates) {
            var lon = v.position_global.coordinates[0];
            var lat = v.position_global.coordinates[1];
            map.put("latitude", lat);
            map.put("longitude", lon);
        }
        if (v.position_local) {
            map.put("position_x", v.position_local.x);
            map.put("position_y", v.position_local.y);
            map.put("position_z", v.position_local.z);
        }
        if (v.accuracy) {
            map.put("position_accuracy", v.accuracy);
        }
    }
    
    // Flatten simple measurements
    if (measurementName != "position" && k == "value") {
        map.put(measurementName, v);
    }
}

// Return result for ThingsBoard
var result = {
    deviceName: deviceName,
    deviceType: deviceType,
    telemetry: map
};

return result;
  1. Click Add to save the converter

Step 2: Create MQTT Integration

  1. Navigate to ThingsBoard → Integrations
  2. Click Add Integration
  3. Configure the integration:
FieldValue
NameHaltian IoT MQTT
TypeMQTT
Uplink data converter(select the converter from Step 1)
Hostmqtt.eu.haltian.io
Port8883
Connection timeout10
Client ID(leave empty or use unique ID)
Enable SSL✅ Checked
UsernameYour API Key ID
PasswordYour API Key Token
  1. Set the topic filter:
haltian-iot/events/{integration-id}/{api-key-id}/#

Replace {integration-id} and {api-key-id} with your actual values.

  1. Click Add to create the integration

Step 3: Verify Data Flow

  1. Navigate to Entities → Devices
  2. Verify new devices appear as MQTT data is received
  3. Devices are named by their Haltian IoT UUID

Check Device Telemetry

  1. Click on a device
  2. Navigate to Latest telemetry tab
  3. Verify measurements are being received:

ThingsBoard Latest Telemetry view showing Thingsee sensor data

KeyExample Value
ambient_temperature.value23.5
ambient_temperature.measured_at2025-01-28T10:30:00.000Z
humidity.value45.2
battery_level.value85

Step 4: Map Device Identifiers

Haltian IoT uses UUIDs for device identification. To map to physical devices:

Option A: Use ThingsBoard Labels

Add the TUID (from device QR code) to the device label:

  1. Edit device in ThingsBoard
  2. Set Label to the TUID (e.g., TSPR04EZU31901021)

Option B: Query Haltian IoT API

Use the Service API to get device mappings:

query GetAllDevices {
  devices(first: 100) {
    edges {
      node {
        id      # UUID used in MQTT
        tuid    # Physical device identifier
        name
      }
    }
  }
}

Step 5: Create Dashboards

Build dashboards using Haltian IoT device data:

  1. Navigate to Dashboards
  2. Create new dashboard
  3. Add widgets with device data sources

Widget Configuration

Widget TypeData KeyDescription
Gaugeambient_temperatureTemperature display
Line Chartambient_temperature.valueTemperature over time
Maplatitude, longitudeAsset location
Cardbattery_level.valueBattery status
Booleanpresence.valuePresence indicator

Example Dashboard Layout

ThingsBoard dashboard example with Thingsee sensor widgets

Haltian IoT MQTT is only for uplink (sensor → cloud). For device commands use Haltian IoT Service API (GraphQL) for device configuration

Troubleshooting

No Devices Appearing

  1. Check integration status in ThingsBoard
  2. Verify MQTT credentials are correct
  3. Ensure topic filter matches your integration/API key IDs
  4. Check ThingsBoard logs for connection errors

Data Not Updating

  1. Verify sensor is sending data (check Haltian IoT Studio)
  2. Check uplink converter for errors
  3. Ensure device hasn’t been renamed in ThingsBoard

Position Data Missing

The basic converter requires enhancement for position data. Use the extended converter above or add specific position handling.

Next Steps