配置LoRa网关后,您需要创建LoRa产品和设备,定义物模型,编写和提交LoRa设备的数据解析脚本。
创建产品和设备
在物联网平台注册LoRa产品和设备。
定义物模型
本示例中,需定义以下属性:温度、湿度、二氧化碳浓度、挥发有机物、甲醛、光照强度和PM2.5。
编写数据解析脚本
本示例中LoRa设备上报的数据是二进制格式。阿里云物联网平台的标准数据格式为Alink JSON格式,不能直接使用二进制数据进行业务处理。对此,物联网平台提供数据解析功能,您可以依据设备数据格式和物模型,编写数据解析脚本,提交至物联网平台,用于解析数据。
附件:物模型TSL
使用时,请替换productKey值为您实际产品的ProductKey值。
{
"schema": "https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json",
"profile": {
"version": "1.0",
"productKey": "h0****fI"
},
"properties": [
{
"identifier": "temperature",
"name": "温度",
"accessMode": "rw",
"desc": "温度",
"required": false,
"dataType": {
"type": "float",
"specs": {
"min": "-20",
"max": "70",
"unit": "°C",
"unitName": "摄氏度",
"step": "0.1"
}
}
},
{
"identifier": "humidity",
"name": "湿度",
"accessMode": "rw",
"required": false,
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "1"
}
}
},
{
"identifier": "co2",
"name": "二氧化碳",
"accessMode": "rw",
"required": false,
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "10000",
"unit": "mg/m³",
"unitName": "毫克每立方米",
"step": "1"
}
}
},
{
"identifier": "voc",
"name": "挥发性有机物",
"accessMode": "rw",
"required": false,
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "1000",
"unit": "mg/m³",
"unitName": "毫克每立方米",
"step": "0.1"
}
}
},
{
"identifier": "hcho",
"name": "甲醛",
"accessMode": "rw",
"desc": "HCHOValue",
"required": false,
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "5",
"unit": "ppm",
"unitName": "百万分率",
"step": "0.1"
}
}
},
{
"identifier": "pm25",
"name": "pm25",
"accessMode": "rw",
"required": false,
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "10000",
"unit": "μg/m³",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "lightLux",
"name": "光照强度",
"accessMode": "rw",
"required": false,
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "10000",
"unit": "Lux",
"unitName": "照度",
"step": "0.1"
}
}
}
],
"events": [
{
"identifier": "post",
"name": "post",
"type": "info",
"required": true,
"desc": "属性上报",
"method": "thing.event.property.post",
"outputData": [
{
"identifier": "temperature",
"name": "温度",
"dataType": {
"type": "float",
"specs": {
"min": "-20",
"max": "70",
"unit": "°C",
"unitName": "摄氏度",
"step": "0.1"
}
}
},
{
"identifier": "humidity",
"name": "湿度",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "1"
}
}
},
{
"identifier": "co2",
"name": "二氧化碳",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "10000",
"unit": "mg/m³",
"unitName": "毫克每立方米",
"step": "1"
}
}
},
{
"identifier": "voc",
"name": "挥发性有机物",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "1000",
"unit": "mg/m³",
"unitName": "毫克每立方米",
"step": "0.1"
}
}
},
{
"identifier": "hcho",
"name": "甲醛",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "5",
"unit": "ppm",
"unitName": "百万分率",
"step": "0.1"
}
}
},
{
"identifier": "pm25",
"name": "pm25",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "10000",
"unit": "μg/m³",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "lightLux",
"name": "光照强度",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "10000",
"unit": "Lux",
"unitName": "照度",
"step": "0.1"
}
}
}
]
}
],
"services": [
{
"identifier": "set",
"name": "set",
"required": true,
"callType": "async",
"desc": "属性设置",
"method": "thing.service.property.set",
"inputData": [
{
"identifier": "temperature",
"name": "温度",
"dataType": {
"type": "float",
"specs": {
"min": "-20",
"max": "70",
"unit": "°C",
"unitName": "摄氏度",
"step": "0.1"
}
}
},
{
"identifier": "humidity",
"name": "湿度",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "1"
}
}
},
{
"identifier": "co2",
"name": "二氧化碳",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "10000",
"unit": "mg/m³",
"unitName": "毫克每立方米",
"step": "1"
}
}
},
{
"identifier": "voc",
"name": "挥发性有机物",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "1000",
"unit": "mg/m³",
"unitName": "毫克每立方米",
"step": "0.1"
}
}
},
{
"identifier": "hcho",
"name": "甲醛",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "5",
"unit": "ppm",
"unitName": "百万分率",
"step": "0.1"
}
}
},
{
"identifier": "pm25",
"name": "pm25",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "10000",
"unit": "μg/m³",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "lightLux",
"name": "光照强度",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "10000",
"unit": "Lux",
"unitName": "照度",
"step": "0.1"
}
}
}
],
"outputData": []
},
{
"identifier": "get",
"name": "get",
"required": true,
"callType": "async",
"desc": "属性获取",
"method": "thing.service.property.get",
"inputData": [
"temperature",
"humidity",
"co2",
"voc",
"hcho",
"pm25",
"lightLux"
],
"outputData": [
{
"identifier": "temperature",
"name": "温度",
"dataType": {
"type": "float",
"specs": {
"min": "-20",
"max": "70",
"unit": "°C",
"unitName": "摄氏度",
"step": "0.1"
}
}
},
{
"identifier": "humidity",
"name": "湿度",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "1"
}
}
},
{
"identifier": "co2",
"name": "二氧化碳",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "10000",
"unit": "mg/m³",
"unitName": "毫克每立方米",
"step": "1"
}
}
},
{
"identifier": "voc",
"name": "挥发性有机物",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "1000",
"unit": "mg/m³",
"unitName": "毫克每立方米",
"step": "0.1"
}
}
},
{
"identifier": "hcho",
"name": "甲醛",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "5",
"unit": "ppm",
"unitName": "百万分率",
"step": "0.1"
}
}
},
{
"identifier": "pm25",
"name": "pm25",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "10000",
"unit": "μg/m³",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "lightLux",
"name": "光照强度",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "10000",
"unit": "Lux",
"unitName": "照度",
"step": "0.1"
}
}
}
]
}
]
}