产品定价 立即试用
目录
如何将 LRS20100 LoRaWAN Temperature and Humidity Sensor 连接至 ThingsBoard?

概述

LRS20100 LoRa环境温湿度传感器是一款高性能多参数传感器,用于监测和报告室内环境的关键指标。 适用于办公室、教室、医院和公共空间,可全面展示空气质量数据,帮助打造舒适、健康的室内环境。

该传感器在紧凑的尺寸内集成了先进的感知技术、灵活的供电方式和远距离无线通信能力。


主要特性

  • 多传感器监测:可测量温度、湿度、二氧化碳 (CO2)、总挥发性有机化合物 (TVOC)、颜粒物 (PM1.0, PM2.5, PM10)。
  • LoRaWAN连接:
    • 远距离、低功耗无线通信。
    • 非常适合智能建筑和IoT集成。
  • 优秀的平台兼容性:
    • 与ThingsBoard、ChirpStack、The Things Stack和LORIOT等主流LoRaWAN网络服务器和平台良好配合。
  • 彩色LED空气质量指示灯:可即时直观反馈空气质量等级,无需仪表板即可快速评估。
  • 灵活供电:支持电池或直流电源供电。

前置条件

继续本指南前,需准备以下内容:

将设备添加到网络服务器

LRS10701使用LoRaWAN技术向ThingsBoard平台发送数据。首先需要配置LoRaWAN网关和网络服务器,确保传感器数据能够达到网络服务器。本指南使用ChirpStack开源LoRaWAN网络服务器。

本指南以OTAA配置的传感器为例。要将设备添加到网络服务器,需要以下信息:

  • Device EUI
  • Application EUI
  • Application Key

这些信息在购买传感器时提供。如需要,请联系您的销售或分销商获取。

首先,您需要将设备添加到ChirpStack:

  • Login to the network server.

  • Go to the “Device profiles” and click “Add device profile”.

  • Input the parameters on the Device Profile page and click Save. For Profile name, input ‘LRS10701-OTAA’ or ‘LRS10701-ABP’ depending on the sensor activation mode configured. It will be used on the data converter to determine the sensor model.

  • Make sure the Payload codec under Codec for the Device Profiles is selected as “None”.

  • Go to Applications, select an existing application or Add application.

  • Click Add device to add the new device.

  • Input the sensor information and click Submit to add the sensor.

  • It will then jump to the OTAA keys page. Input the Application Key of the sensor and click Submit.

在ThingsBoard中创建设备

请参考此页面的指南,在ThingsBoard账户中创建ChirpStack集成,并在ChirpStack应用中配置集成。

导入JSON文件SENSO8_data_converter_for_chirpstack_integration.json,或复制以下payloadDecoder函数代码。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
var deviceType = metadata.deviceProfileName; 
var fPort = metadata.fPort;

/**
Decodes the incoming payload and returns a structured object containing telemetry data and attributes.

@param {byte[]} input - The raw payload received as an array of bytes.
@returns {Object} output - The structured output with decoded telemetry and attributes.

*/

function decodePayload(input) {
 // Initialize the output object with empty attributes and telemetry for clarity. 
 var result = { attributes: {}, telemetry: {}};

 // Decode serial number (SN) from the first 4 bytes of the payload.
  // Press '?' icon in the top right corner to learn more about built in helper functions and capabilities.
  result.attributes.sn = parseBytesToInt(input, 0, 4);

  // Extract the timestamp from metadata (represented in milliseconds).
  var timestamp = metadata.ts; // ts is the timestamp parsed from the incoming message's time, or returns the current time if it cannot be parsed.

  // Initialize an object to store decoded key/value telemetry data.
  var values = {};
  if ((deviceType === 'LRS10701-OTAA') || (deviceType === 'LRS10701-ABP')) {
    if (fPort === 10) {
        // Decode event from the 1st byte of the payload.
        values.event = parseBytesToInt(input, 0, 1);

        // Decode AQI, CO2 and temperature from the 2nd to 5th byte of the payload.
        var AQI_CO2_T = parseBytesToInt(input, 1, 4);
        values.aqi = AQI_CO2_T >> 23;
        values.co2 = (AQI_CO2_T >> 10)&0x1FFF;
        values.temperature = ((AQI_CO2_T & 0x3FF) - 300)*0.1;

        // Decode humidity from the 6th byte of the payload.
        values.humidity = parseBytesToInt(input, 5, 1)*0.5;

        // Decode battery level and EC sensor resolution from the 11th byte of the payload.
        var ecr_bat = parseBytesToInt(input, 10, 1);
        var ec_res = ecr_bat >> 7;
        if (ec_res === 1) 
            ec_scale = 10;
        else
            ec_scale = 1000;
        values.battery = ecr_bat & 0x7F;
        
        // Decode gas sensor readings from the 7th to 8th and 9th to 10th byte of the payload.    
        values.gas1 = parseBytesToInt(input, 6, 2)/ec_scale;
        values.gas2 = parseBytesToInt(input, 8, 2)/ec_scale;
      } else if (fPort === 11) {
        // Decode TVOC from the 1st and 2nd byte of the payload.
        values.tvoc = parseBytesToInt(input, 0, 2);
        // Decode PM1.0 from the 3rd to 5th byte of the payload.
        values["pm1.0"] = parseBytesToInt(input, 2, 3)/1000;
        // Decode PM2.5 from the 6th to 8th byte of the payload.
        values["pm2.5"] = parseBytesToInt(input, 5, 3)/1000;
        // Decode PM10 from the 8th to 11th byte of the payload.
        values.pm10 = parseBytesToInt(input, 8, 3)/1000;
      }
  }

  if ((deviceType === 'LRS20100-OTAA') || (deviceType === 'LRS20100-ABP')) {
    if (fPort === 10 && parseBytesToInt(input, 0, 1) === 1) {
        // Decode event from the 2nd byte of the payload.
        values.event = parseBytesToInt(input, 1, 1);

        // Decode temperature from the 4th and 5th byte of the payload.
        var temperature = parseBytesToInt(input, 3, 2);
        if (temperature > 32767) 
            temperature = temperature - 65536;
        values.temperature = temperature/10;

        // Decode humidity from the 6th and 7th byte of the payload.
        values.humidity = parseBytesToInt(input, 5, 2)/10;

        // Decode battery level the 3rd byte of the payload.
        values.battery = parseBytesToInt(input, 2, 1);
    }        
  }

  // Combine the timestamp with values and add it to the telemetry.
  result.telemetry = {
    ts: timestamp,
    values: values
  };

  // Return the fully constructed output object.
  return result;
 
}

var result = decodePayload(payload); 

return result;

有关高级解码参数,请参考以下截图。

image

将设备添加到ChirpStack并在ThingsBoard和ChirpStack上都完成集成配置后,当设备发送任何数据时,ThingsBoard界面上将自动出现新设备。

在ThingsBoard上查看数据

要查看接收到的数据,可前往“实体”下的“设备”页面,然后从设备列表中选择新创建的设备。

image

接收到的数据可在“属性”和“最新遥测”页面中查看。

image

ThingsBoard提供更友好的仪表板方式来可视化您的数据。

ThingsBoard允许您创建和自定义仪表板以满足需求。

如果您想快速体验仪表板,可以下载此文件并导入到ThingsBoard中。

要导入仪表板,请按以下步骤操作:

  • 进入 “仪表板” 页面,点击右上角的 + 按钮。

  • 从下拉菜单中选择 “导入仪表板“。

  • 选择下载的文件或将文件拖拽到对话框中,点击 “Import“。

  • 导入仪表板后将返回仪表板列表,点击选择并打开导入的仪表板。

  • 点击编辑模式更新仪表板。

  • 将鼠标悬停在部件上,右上角会显示控件,点击 铅笔 图标进行编辑。

  • 弹出部件属性设置对话框。点击 Datasource 下的 Device 选择要监控的设备,然后点击 Apply

  • 对其他部件重复以上步骤。最后点击 Save 保存更改,仪表板即可用于监控新设备。

总结

通过本指南的介绍,您可以轻松连接LRS10701 LoRaWAN IAQ传感器并在ThingsBoard上可视化数据。

请探索平台文档,了解更多ThingsBoard的核心概念和功能,如配置告警规则仪表板

发现即插即用硬件,助力您的解决方案
合作伙伴图标