硬件端端介绍

一. 系统拓扑图

  1. 蜂巢网关可以自动或者按需采集温湿度、PM2.5数据
  2. 蜂巢网关按照MQTT协议,将采集的数据上传到MQTT服务器
  3. 蜂巢网关可以控制风扇、灯光、蜂鸣器的动作
  4. MQTT服务器配置设备、接收并存储设备数据
  5. NODE-RED具备拖拽编程能力

二、程序框架介绍

  1. 蜂巢STM32底座程序,全部放在WIFI模块目录下
  2. 每个底座的STM32程序,按照keil开发工具常用标准,HARDWARD中是外设驱动代码,CORE是MCU核心代码,USER中是应用主程序和项目文件
  3. 蜂巢网关ESP32模块采用VS+IDF4.4开发,components中是公用外设驱动,main中是应用主程序

三、演示操作流程

1. 模拟项目背景

城市的污水管网状态数据采集、危险报警及云端运维。

2.操作步骤

    1. 为演示效果,用PM2.5传感器代替甲烷传感器
    1. 首先修改蜂巢网关的SMT32程序,将WIFI参数传递给WIFI模块,如果WIFI模块上面的三个LED指示灯全部亮,表示正确连接MQTT服务器。同时将网关设置为本地循环控制,网关流读取显示温湿度数据、 PM2.5浓度数据,同时主动上传到MQTT
    1. PM2.5浓度大于阈限值,灯光闪烁报警、蜂鸣器报警,同时开启风扇;PM2.5浓度下降到阈值限值以下,灯光报警停止、蜂鸣器报警停止,同时风扇停止;
    1. 在物联网平台,可以看到温湿度数据、PM2,5浓度值在MQTT中间件中以JSON结构显示。
    1. 将蜂巢网关的SMT32程序修改为远程指令控制,在NODERED中可以发送指令获取数据;NODERED中设置温度阈值,用人体提高传感器温度,达到阈值后,NODERED自动下发指令启动风扇运行和开启LED灯光;温度下降到低于阈值后,NODERED自动下发指令停止风扇运行,关闭LED灯光。

四、蜂巢网关介绍

  1. 蜂巢网关配置的ESP32模块,已经将MQTT服务器接入参数写入模块NVS中,但是WIFI参数需实际情况修改。蜂巢网关底盒STM32可以通过串口将参数写入ESP32模块。
  2. 蜂巢网关可以通过修改配置参数,可以实现本地读取传感器数据,并按照阈值范围实现报警联动
  3. 蜂巢网关通过底盒的RS485总线与其他设备相连,实现数据的通讯

## 五、温湿度模块介绍

  1. 温湿度模块的地址、操作代码、数据代码,都在RS485.h中定义
  2. 温湿度模块,不会主动向485总线发送数据,485数据接收的处理在定时器3的中断中统一处理的,按照不同的指令代码,返回对应的数据到指令发送设备

六、PM2.5模块介绍

  1. 在主循环中,不停采集P,2.5数据,同时解析接收到的RS485指令,如果是采集PM2.5的,就发送PM2.5浓度数据道总线
  2. 可以通过吹气,改变PM2.5浓度数据,如果需要大幅改变,可以通过吹入香烟等测试

七、LED模块介绍

  1. 在定时器3中的中断中,处理接收到的RS485数据,如果是本设备控制指令,执行对应操作

八、风扇模块介绍

  1. 在定时器3的中断中处理RS485数据,如果是本设备控制指令,执行相关动作
  2. 分别用500、1200、1500定时器4的PWM参数来表达高速、中速、低速三种转速

九、蜂鸣器模块介绍

  1. 在定时器3的中断中处理RS485指令,如果是本机控制指令置对应标志
  2. 在主循环中判断动作标志,开启蜂鸣器或者关闭蜂鸣器
  3. 蜂鸣器开启有时间参数,即延时循环,因此不能再定时器3的中断中直接调用

八城工业物联网平台

谷歌浏览器打开网页 https://iiot.stepiot.com ,点击右上角【控制台】,如图: 输入账号和密码,进行登录 登录成功后,点击左侧【事务管理】->【设备管理】,选择相应的组,查看该组下所有设备

如果列表为空,需要把默认的勾选去掉:如图:

Node-RED使用

1. 进入界面

打开google浏览器,在输入网址处输入(http://127.0.0.1:1880 ),如下图:

2.控制设备

界面左上角搜索 mqtt ,如图

拖动网络下组别下的 mqtt out 模块到操作界面,如图 双击mqtt控件,点击右侧新增一个mqtt-broker节点: 进入如下界面,点击【使用TLS】,添加新的tls-config节点,如图: 进入如下界面: 浏览器新建一个tab,进入八城工业物联网平台,找到对应组下的类型为【程序客户端客户端】的设备,如图 点击【详情】,选择【连接信息】tab,下载Certificate File,Private Key File,RSA 2048 bit Amazon Root CA,如图: 切换回Node-RED界面,把刚刚下载下来的三个密钥上传到该界面,证书 对应 certificate.pem.crt文件,私钥对应 private.pem.key文件,CA证书对应 aws-root-ca.pem文件,并且记下Client ID,然后我们把名称设置为【程序客户端】如图: 点击右上角【添加】后如图: 服务端地址填上:a2kob4few2zw49-ats.iot.cn-northwest-1.amazonaws.com.cn 端口填上: 8883,客户端ID填入刚刚记下的Client ID,并在名称输入 程序客户端,如图: 点击右上角【添加】,进入如图界面:

这里填入需要监控的设备的主题,主题在八城工业物联网平台的该设备【连接信息】下面,比如现在我们要监控教室里面【蜂巢网关】的信息,找到该设备,进入详情,点击【连接信息】tab,找到【设备连接信息】框,复制Data Topic 主题即可,如图:

将复制出来的主题复制到Node-RED平台的主题输入框里面,名称我们命名为【蜂巢网关】,如图:

点击右上角【完成】,信息框隐藏,然后点击右上角【部署】,完成部署。

主键左下角出现【已连接】的字样,即表示配置完成。如图:

至此,我们配置完成了一个蜂巢网关设备的mqtt配置。接下来我们编写解析函数。我们通过mqtt提前约定一个json格式,硬件端和平台端,可以通过这个json的字段约定来进行解释操作。我们约定的json格式如下:

  1. 下行
    {
    "thingname": "${thingname}",
    "group": "${groupid}",
    "topic": "${topic}",
    "timestamp": "当前时间",                 //服务当前时间
    "devicetype": "${devicetype}",
    "cmd": [
            {
         	"led1":1,                     //LED1灯开关,1--打开;0--关闭
          "led2":1,                     //LED1灯开关,1--打开;0--关闭
          "led3":1,                     //LED1灯开关,1--打开;0--关闭
          "led4":1,                     //LED1灯开关,1--打开;0--关闭
         	"fan":1,                     //风扇控制0-关闭 1、2、3-档位
          "relay1":1                  //继电器控制
          "relay2":1                  //继电器控制
          "motor":1                 //电机控制
          "SHT20GetAll":1        //获取SHT20数据(温度、湿度、光照)
          "HFRFIDGetAll":1        //读高频卡
          "gyrGetAngle":1       //获取陀螺仪角度
          "PIRGetState":1        //获取人体感应状态
          "GPSGetLocation":1    //获取GPS数据
          "ultrasonicGetDis":1   //获取超声波距离
          "PM25GetConc":1    //获取PM2.5浓度
          "flameGetState":1     //获取火焰传感器状态
          "shockGetCount":1   //获取震动次数
          "heartGetCount":1    //获取心率值
          "LFRFIDGetAll":1     //读低频卡
          "APGetAltitude":1   //获取大气压力(海拔高度)
          "PHGetState":1     //获取光电开关状态
          "touchKeyGetState":1    //获取触摸按键状态
          "TFGetData":1          //获取TF卡数据
          "alcoholGetState":1   //获取酒精传感器状态
          "alcoholGetData":1   //获取酒精传感器数据
          "formaldehydeGetData":1    //获取甲醛浓度数据
          "smokeGetState":1     //获取烟雾传感器状态
          "smokeGetData":1     //获取烟雾传感器数据
          "colorGetData":1    //获取色彩传感器数据
          "noncontactTempGetData":1    //获取非接触式温度传感器数据
          "moistureGetData":1    //获取土壤湿度数据
          "gestureGetAction":1   //获取传感器动作
          "NFCGetID":1,          //获取NFC卡ID
          "BEEP":1 //1开0关
         }
        ]
    }
    
  2. 下行
    {
     "thingname": "${thingname}",
     "group": "${groupid}",
     "topic": "${topic}",
     "timestamp": "当前时间",
     "devicetype": "${devicetype}",
     "data"[
     {
       	"SHT20Temp":20,                //温度
         "SHT20Humi":50                 //湿度
         "SHT20_Light":100           //光照
         "matrixkey":0      //按键值 0~9 enter canel up down left right 
         "preWeight":40     //压力(重量)
         "HFFIDID":4f3278    //高频卡ID
         "HFRFIDBlock":xxxxx    //高频卡块数据
         "gyrAngle":37     //陀螺仪角度
         "PIRState":1      //人体红外状态
         "GPSLocation":xxxx.xxxxxxxxx       //GPS经纬度数据
         "ultrasonicDis":30             //超声波距离(cm)
         "PM25Conc":10      //PM2.5浓度值
         "flameState":1       //火焰传感器状态
         "shockCount":32     //震动次数
         "heartCount":80    //每分钟心跳次数
         "LFRFIDID":xxxxxxx    //低频卡ID
         "LFRFIDBlock"xxxxxxxxxxxxxxx   //低频卡块数据
         "APAltitude"1800   //大气压力(海拔高度)
         "PHState":1    //光电开关状态
         "touchKeyState":1   //触摸开关状态
         "TFData":xxxxxxxxxxxxxxx    //TF卡数据
         "alcoholData":47      //酒精浓度数据
         "alcoholState":1      //酒精检测状态
         "formaldehydeData":29   //甲醛浓度数据
         "smokeData":89         //烟感浓度数据
         "smokeState":1         //烟感状态
         "colorData":255       //色彩传感器RGB数据
         "noncontactTempData":23   //非接触式温度传感器数据
         "moistureData":78      //土壤湿度数据
         "gesture_Action":up    //up down left right beyond near
         "NFCID":xxxxxxxxxxxxx     //NFC卡ID
      }
     ]
    }
    

    左上角inject组件拖入操作区,如图: 双击点开,设置如下,名称为:电灯:开,msg.payload为1,如图: 点击完成,同样的流程,我们分别设置电灯:关,风扇:开,风扇:关,蜂鸣:开,蜂鸣:关,获取温湿度,获取PM2.5的命令值,他们依次为:2,3,4,5,6,7,8。设置完成后如图:

将左侧的function组件拖入操作区,如图: 双击函数组件,复制如下代码:

var flag=msg.payload;
msg.payload={
    "thingname": "64107303e4b0dabda686037d",
    "group": "1528546145080545282",
    "topic": "stepiot/data/1271087791777910784/1528546145080545282/64107303e4b0dabda686037d",
    "timestamp": new Date().getTime(),
    "devicetype": "action_honeycomb_wifi",
    } 
if(flag===1){
   msg.payload.cmd=[{
		    "led1": 1,
		    "led2": 1,
		    "led3": 1,
		    "led4": 1
	    }]
}
if(flag===0){
    msg.payload.cmd= [{
		   "led1": 0,
		   "led2": 0,
		   "led3": 0,
		   "led4": 0
	    }]
}
if(flag===3){
    msg.payload.cmd= [{
		    "fan": 3
	    }]
}
if(flag===4){
    msg.payload.cmd= [{
		    "fan": 0
	    }]
}
if(flag===5){
    msg.payload.cmd= [{
		    "BEEP": 1
	    }]
}
if(flag===6){
    msg.payload.cmd= [{
		    "BEEP": 0
	    }]
}
if(flag===7){
    msg.payload.cmd= [{
		    "SHT20GetAll": 1
	    }]
}
if(flag===8){
    msg.payload.cmd= [{
		    "PM25GetConc": 1
	    }]
}
return msg;

然后们将他们连线起来,如图: 点击右上角【部署】,就可以控制设备了

获取传感器设备数值

左上角搜索mqtt,将mqtt in组件拖入操作区,如图: 双击该组件,服务器选择刚刚设置的程序客户端,主题填写刚刚复制的蜂巢网关主题,QoS设置为0,名称我们命名为蜂巢网关,如图: 左侧拖入function组件,如图: 双击函数,填入如下代码:

var payload=JSON.parse(msg.payload);
var exp=payload.data;
if(typeof(exp) != "undefined"){
    var PM25Conc=payload.data[0].PM25Conc;
    var SHT20Temp=payload.data[0].SHT20Temp;
    var SHT20Humi=payload.data[0].SHT20Humi;
    var intPM25=parseInt(PM25Conc);
    var intTemp=parseInt(SHT20Temp);
    var intHumi=parseInt(SHT20Humi);
if(intPM25>=0){
    payload.data[0].PM25Conc=intPM25;
}else{
    payload.data[0]=0;
}
if(intTemp>=0){
    payload.data[0].SHT20Temp=intTemp;
}else{
    payload.data[0].SHT20Temp=0;
}
if(intHumi>=0){
    payload.data[0].SHT20Humi=intHumi;
}else{
    payload.data[0].SHT20Humi=0;
}
}else{
    payload.data[0].PM25Conc=0;
    payload.data[0].SHT20Temp=0; 
    payload.data[0].SHT20Humi=0;
}
return msg;

点击完成 左侧输入gauge,然后将组件拖入操作区,如图: 双击gauge组件,添加新的ui_group节点,如图 添加新的ui_tab节点,如图: 然后填入传感设备,如图: 点击添加,然后再dashboard group窗口填上传感设备,如图: 点击添加,然后再gauge节点的 Label输入 温度 , Value format输入框输入: ,Units输入 摄氏度,如图:

点击完成,然后连接组件,如图 然后浏览器输入: http://127.0.0.1:1880/ui 界面如下:

## 设备联动 我们来设置当温度超过35摄氏度的时候,启动风扇,小于35摄氏度关闭风扇。首先,拖入function节点进入操作区,然后粘贴如下代码:

 var payload=JSON.parse(msg.payload);
var SHT20Temp=payload.data[0].SHT20Temp;
if(SHT20Temp>=35){
   msg.payload.cmd= [{
		    "fan": 3
	    }]
}else{
    msg.payload.cmd= [{
		    "fan": 0
	    }]
}
return msg;

界面如下:

点击完成,然后连接相应组件,如下:

附:

完整的Node-RED代码如下:

[{"id":"a2c459dc.b6e638","type":"tab","label":"蜂巢Node-RED","disabled":false,"info":""},{"id":"93b16947.19ce88","type":"mqtt in","z":"a2c459dc.b6e638","name":"蜂巢网关","topic":"stepiot/data/1691726982939774977/1691727242785296386/64dc8992e4b052be9999059e","qos":"0","datatype":"auto","broker":"891971a0.ab55f","nl":false,"rap":true,"rh":0,"x":480,"y":220,"wires":[["b8f421a2.20ce8","6dcf8d6a.6bf7c4"]]},{"id":"c673c724.0a6138","type":"function","z":"a2c459dc.b6e638","name":"","func":"var flag=msg.payload;\nmsg.payload={\n    \"thingname\": \"64dc8992e4b052be9999059e\",\n    \"group\": \"1691727242785296386\",\n    \"topic\": \"stepiot/data/1691726982939774977/1691727242785296386/64dc8992e4b052be9999059e\",\n    \"timestamp\": new Date().getTime(),\n    \"devicetype\": \"action_honeycomb_wifi\",\n    } \nif(flag===1){\n   msg.payload.cmd=[{\n\t\t    \"led1\": 1,\n\t\t    \"led2\": 1,\n\t\t    \"led3\": 1,\n\t\t    \"led4\": 1\n\t    }]\n}\nif(flag===0){\n    msg.payload.cmd= [{\n\t\t   \"led1\": 0,\n\t\t   \"led2\": 0,\n\t\t   \"led3\": 0,\n\t\t   \"led4\": 0\n\t    }]\n}\nif(flag===3){\n    msg.payload.cmd= [{\n\t\t    \"fan\": 3\n\t    }]\n}\nif(flag===4){\n    msg.payload.cmd= [{\n\t\t    \"fan\": 0\n\t    }]\n}\nif(flag===5){\n    msg.payload.cmd= [{\n\t\t    \"BEEP\": 1\n\t    }]\n}\nif(flag===6){\n    msg.payload.cmd= [{\n\t\t    \"BEEP\": 0\n\t    }]\n}\nif(flag===7){\n    msg.payload.cmd= [{\n\t\t    \"SHT20GetAll\": 1\n\t    }]\n}\nif(flag===8){\n    msg.payload.cmd= [{\n\t\t    \"PM25GetConc\": 1\n\t    }]\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":620,"wires":[["d86b6e48.7a69f"]]},{"id":"9d2be2a0.d109c","type":"inject","z":"a2c459dc.b6e638","name":"蜂巢电灯:开","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":350,"y":320,"wires":[["c673c724.0a6138"]]},{"id":"a0dda451.17b508","type":"inject","z":"a2c459dc.b6e638","name":"蜂巢电灯:关","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":350,"y":380,"wires":[["c673c724.0a6138"]]},{"id":"d56737d1.4d78a8","type":"inject","z":"a2c459dc.b6e638","name":"蜂巢风扇:开","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"3","payloadType":"num","x":350,"y":460,"wires":[["c673c724.0a6138"]]},{"id":"da3eb35f.2df5b","type":"inject","z":"a2c459dc.b6e638","name":"蜂巢风扇:关","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4","payloadType":"num","x":350,"y":520,"wires":[["c673c724.0a6138"]]},{"id":"de3ae5a2.e89278","type":"inject","z":"a2c459dc.b6e638","name":"蜂巢蜂鸣:开","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"5","payloadType":"num","x":350,"y":580,"wires":[["c673c724.0a6138"]]},{"id":"774706e7.0f5d48","type":"inject","z":"a2c459dc.b6e638","name":"蜂巢蜂鸣:关","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"6","payloadType":"num","x":350,"y":640,"wires":[["c673c724.0a6138"]]},{"id":"91dcda71.b0fe48","type":"inject","z":"a2c459dc.b6e638","name":"蜂巢获取温湿度","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"7","payloadType":"num","x":360,"y":700,"wires":[["c673c724.0a6138"]]},{"id":"ae593491.d6dd98","type":"inject","z":"a2c459dc.b6e638","name":"蜂巢获取PM2.5","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"8","payloadType":"num","x":360,"y":760,"wires":[["c673c724.0a6138"]]},{"id":"d86b6e48.7a69f","type":"mqtt out","z":"a2c459dc.b6e638","name":"蜂巢网关","topic":"stepiot/data/1691726982939774977/1691727242785296386/64dc8992e4b052be9999059e","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"891971a0.ab55f","x":840,"y":620,"wires":[]},{"id":"5a7fd42f.29d7fc","type":"switch","z":"a2c459dc.b6e638","name":"温度条件","property":"payload.data[0].SHT20Temp","propertyType":"msg","rules":[{"t":"gte","v":"1","vt":"num"},{"t":"lte","v":"100","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":900,"y":360,"wires":[[],[]]},{"id":"b8f421a2.20ce8","type":"json","z":"a2c459dc.b6e638","name":"转为JSON","property":"payload","action":"","pretty":true,"x":670,"y":220,"wires":[["5a7fd42f.29d7fc","a28fe94b.a59308","804b34e7.06c958","a0c6dad9.2264c8","62ba0c0e.c04f34","f1175361.2d03a","21a71265.35aa8e","ef09a81b.8b4708"]]},{"id":"a0c6dad9.2264c8","type":"switch","z":"a2c459dc.b6e638","name":"湿度条件","property":"payload.data[0].SHT20Humi","propertyType":"msg","rules":[{"t":"gte","v":"1","vt":"num"},{"t":"lte","v":"100","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":900,"y":420,"wires":[[],[]]},{"id":"a28fe94b.a59308","type":"switch","z":"a2c459dc.b6e638","name":"PM2.5条件","property":"payload.data[0].PM25Conc","propertyType":"msg","rules":[{"t":"gte","v":"1","vt":"num"},{"t":"lte","v":"100","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":910,"y":300,"wires":[[],[]]},{"id":"804b34e7.06c958","type":"switch","z":"a2c459dc.b6e638","name":"光照条件","property":"payload.data[0].SHT20Light","propertyType":"msg","rules":[{"t":"gte","v":"1","vt":"num"},{"t":"lte","v":"100","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":900,"y":240,"wires":[[],[]]},{"id":"f1175361.2d03a","type":"ui_gauge","z":"a2c459dc.b6e638","name":"","group":"8a22f4ba.9893b8","order":0,"width":0,"height":0,"gtype":"gage","title":"湿度","label":"RH","format":"","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":890,"y":60,"wires":[]},{"id":"21a71265.35aa8e","type":"ui_gauge","z":"a2c459dc.b6e638","name":"","group":"8a22f4ba.9893b8","order":0,"width":0,"height":0,"gtype":"gage","title":"PM2.5","label":"um","format":"","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":890,"y":180,"wires":[]},{"id":"62ba0c0e.c04f34","type":"ui_gauge","z":"a2c459dc.b6e638","name":"","group":"8a22f4ba.9893b8","order":0,"width":0,"height":0,"gtype":"gage","title":"光照","label":"lx","format":"","min":0,"max":"10000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":890,"y":20,"wires":[]},{"id":"ef09a81b.8b4708","type":"ui_gauge","z":"a2c459dc.b6e638","name":"","group":"8a22f4ba.9893b8","order":0,"width":0,"height":0,"gtype":"gage","title":"温度","label":"摄氏度","format":"","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":890,"y":120,"wires":[]},{"id":"6dcf8d6a.6bf7c4","type":"function","z":"a2c459dc.b6e638","name":"解析数据","func":"var payload=JSON.parse(msg.payload);\nvar exp=payload.data;\nif(typeof(exp) != \"undefined\"){\n    var PM25Conc=payload.data[0].PM25Conc;\n    var SHT20Temp=payload.data[0].SHT20Temp;\n    var SHT20Humi=payload.data[0].SHT20Humi;\n    var intPM25=parseInt(PM25Conc);\n    var intTemp=parseInt(SHT20Temp);\n    var intHumi=parseInt(SHT20Humi);\nif(intPM25>=0){\n    payload.data[0].PM25Conc=intPM25;\n}else{\n    payload.data[0]=0;\n}\nif(intTemp>=0){\n    payload.data[0].SHT20Temp=intTemp;\n}else{\n    payload.data[0].SHT20Temp=0;\n}\nif(intHumi>=0){\n    payload.data[0].SHT20Humi=intHumi;\n}else{\n    payload.data[0].SHT20Humi=0;\n}\n}else{\n    payload.data[0].PM25Conc=0;\n    payload.data[0].SHT20Temp=0; \n    payload.data[0].SHT20Humi=0;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":480,"wires":[["69eca5b0.770aac"]]},{"id":"69eca5b0.770aac","type":"function","z":"a2c459dc.b6e638","name":"设置条件","func":"var payload=JSON.parse(msg.payload);\n//pm2.5\nvar PM25Conc=payload.data[0].PM25Conc;\n//温度\nvar SHT20Temp=payload.data[0].SHT20Temp;\n//湿度\nvar SHT20Humi=payload.data[0].SHT20Humi;\nif(PM25Conc>50){\n    \n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":480,"wires":[[]]},{"id":"891971a0.ab55f","type":"mqtt-broker","name":"程序客户端","broker":"a2kob4few2zw49-ats.iot.cn-northwest-1.amazonaws.com.cn","port":"8883","tls":"c0908e18.90b2c","clientid":"64dc89a3e4b052be9999059f","usetls":true,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"8a22f4ba.9893b8","type":"ui_group","name":"传感器","tab":"ff072c4e.e901f","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"c0908e18.90b2c","type":"tls-config","name":"程序客户端","cert":"","key":"","ca":"","certname":"certificate.pem.crt","keyname":"private.pem.key","caname":"aws-root-ca.pem","servername":"","verifyservercert":true},{"id":"ff072c4e.e901f","type":"ui_tab","name":"传感器面板","icon":"dashboard","disabled":false,"hidden":true}]