微信小程式-MQTT模拟器
微信小程式碼

1. 準備工作
1.1 注冊阿裡雲賬号
開通阿裡雲賬号,并通過支付寶實名認證
https://www.aliyun.com1.2 免費開通IoT物聯網套件
産品官網
https://www.aliyun.com/product/iot2. 控制台操作步驟
2.1 建立進階版産品
進階版,JSON格式
完整物模型TSL,可以在控制台導入,需要替換productKey
2.2 産品功能定義
添加産品屬性
溫度 temperature,濕度 humidity
2.3 注冊裝置
在産品下注冊裝置,獲得身份三元組
3. 微信小程式操作
3.1 裝置上線
3.2 上報資料
3.3 訂閱主題和資料下行
先點選 訂閱主題,再去控制台推送消息。
人臉識别彩蛋
IoT物聯網技術
附錄:物模型TSL
{
"schema": "https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json",
"profile": {
"productKey": "替換為你的productKey"
},
"services": [
{
"outputData": [],
"identifier": "set",
"inputData": [
{
"identifier": "temperature",
"dataType": {
"specs": {
"unit": "°C",
"min": "0",
"max": "1000",
"step": "0.1"
},
"type": "float"
},
"name": "溫度"
},
{
"identifier": "humidity",
"dataType": {
"specs": {
"unit": "%RH",
"min": "0",
"max": "100",
"step": "0.1"
},
"type": "float"
},
"name": "濕度"
}
],
"method": "thing.service.property.set",
"name": "set",
"required": true,
"callType": "async",
"desc": "屬性設定"
},
{
"outputData": [
{
"identifier": "temperature",
"dataType": {
"specs": {
"unit": "°C",
"min": "0",
"max": "1000",
"step": "0.1"
},
"type": "float"
},
"name": "溫度"
},
{
"identifier": "humidity",
"dataType": {
"specs": {
"unit": "%RH",
"min": "0",
"max": "100",
"step": "0.1"
},
"type": "float"
},
"name": "濕度"
}
],
"identifier": "get",
"inputData": [
"temperature",
"humidity"
],
"method": "thing.service.property.get",
"name": "get",
"required": true,
"callType": "async",
"desc": "屬性擷取"
}
],
"properties": [
{
"identifier": "temperature",
"dataType": {
"specs": {
"unit": "°C",
"min": "0",
"max": "1000",
"step": "0.1"
},
"type": "float"
},
"name": "溫度",
"accessMode": "rw",
"required": false
},
{
"identifier": "humidity",
"dataType": {
"specs": {
"unit": "%RH",
"min": "0",
"max": "100",
"step": "0.1"
},
"type": "float"
},
"name": "濕度",
"accessMode": "rw",
"required": false
}
],
"events": [
{
"outputData": [
{
"identifier": "temperature",
"dataType": {
"specs": {
"unit": "°C",
"min": "0",
"max": "1000",
"step": "0.1"
},
"type": "float"
},
"name": "溫度"
},
{
"identifier": "humidity",
"dataType": {
"specs": {
"unit": "%RH",
"min": "0",
"max": "100",
"step": "0.1"
},
"type": "float"
},
"name": "濕度"
}
],
"identifier": "post",
"method": "thing.event.property.post",
"name": "post",
"type": "info",
"required": true,
"desc": "屬性上報"
}
]
}