立即试用 商务报价
专业版
文档 > 集成整合 > Azure IoT Hub

本页目录

Azure IoT Hub Integration

ThingsBoard PE功能

仅限专业版支持Platform Integrations功能。
基于ThingsBoard云服务专业版平台实例。

Overview

Azure IoT Hub Integration allows to stream data from AWS IoT Backend to ThingsBoard and converts device payloads to the ThingsBoard format.

Create and configure Azure IoT Hub account

Integration with the Thingsboard

We have done all necessary steps on the Azure IoT Hub side. Now we can start configuring the Thingsboard.

First, we need to create Uplink Data converter that will be used for converting messages received from the Azure IoT Hub. The converter should transform incoming payload into the required message format. Message must contains deviceName and deviceType. Those fields are used for submitting data to the correct device. If a device was not found then new device will be created. Here is how demo payload from the Azure IoT Hub will look like:

1
2
3
4
5
6
7
{
    "devName": "T1",
    "msg": {
        "temp": 42,
        "humidity": 77
    }
}

We will take devName and map it to the deviceName. But you can use another mapping in your specific use cases. Also, we will take the value of the temperature and humidity fields and use it as a device telemetry.

Go to Data Converters and create new uplink Converter with this function:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var data = decodeToJson(payload);
var deviceName = data.devName;
var deviceType = 'thermostat';

var result = {
   deviceName: deviceName,
   deviceType: deviceType,
   telemetry: {
       temperature: data.msg.temp,
       humidity: data.msg.humidity
   }
};

function decodeToString(payload) {
   return String.fromCharCode.apply(String, payload);
}

function decodeToJson(payload) {
   var str = decodeToString(payload);
   var data = JSON.parse(str);
   return data;
}

return result;

image

Azure IoT Hub Integration

Next we will create Integration with Azure IoT Hub inside the Thingsboard. Open Integrations section and add new Integration with type Azure IoT Hub

  • Name: IoT Hub
  • Type: Azure IoT Hub
  • Uplink data converter: Thermostat Converter
  • Hostname: AZURE_IOT_HUB_HOSTNAME
  • Device ID: T1
  • Credentials: Shared Access Signature
  • SAS Key: DEVICE_SAS_KEY
  • Topic filter: devices/T1/messages/devicebound/#

image

  • Topic - for more information about IoT Hub topic use link.
  • Credentials - Azure IoT Hub connection credentials. Can be either Shared Access Signature or PEM.

Different Authentication credentials are supported for Azure IoT Hub:

  • Shared Access Signature - SAS Key is used for Authentication
  • PEM - PEM certificates are used for Authentication

If Shared Access Signature credentials type is selected, the following configuration should be provided:

  • SAS Key - it is key from your device in Azure IoT Hub
  • CA certificate file, by default used Baltimore certificate. More about certificates here

If PEM credentials type is selected, the following configuration should be provided:

  • CA certificate file, by default used Baltimore certificate. More about certificates here
  • Certificate file
  • Private key file
  • Private key password

X.509 CA-signed authentication

CACertificates instruction

Validation

Lets verify our integration. First, lets put message into uplink stream, so Thingsboard will fetch this message.

Open page with your Device and go to Message to Device.

Send test message to device.

image

Go to Device Group -> All -> T1 - you can see that

  • new device was registered in the thingsboard
  • In the Latest Telemetry section you will see that last submitted temperature = 42 and humidity = 77.

image

Next steps

  • 入门指南 - 快速学习ThingsBoard相关功能。

  • 安装指南 - 学习如何在各种操作系统上安装ThingsBoard。

  • 可 视 化 - 学习如何配置复杂的ThingsBoard仪表板说明。

  • 数据处理 - 学习如何使用ThingsBoard规则引擎。

  • 数据分析 - 学习如何使用规则引擎执行基本的分析任务。

  • 硬件样品 - 学习如何将各种硬件平台连接到ThingsBoard。

  • 高级功能 - 学习高级ThingsBoard功能。