2023年12月31日 星期日

Node-Red MQTT基本實驗

 Node-Red MQTT基本實驗













ON Bouuton 節點

Payload : on

OFF Bouuton 節點

Payload : off

MQTT out節點

Server :broker.hivemq.com : 1883

Qos=1  保留:

發行主題 : alex9ufo/node-red/out

MQTT in節點

Server :broker.hivemq.com : 1883

Qos=1  保留:

發行主題 : alex9ufo/node-red/out

Audio Out 節點

1.     Microsoft Yatinf—Chinese

Function 節點

var onoff=msg.payload;

 

if (onoff=="on")

{

    msg.payload=true;

}

if (onoff=="off")

{

    msg.payload=false;

return msg;

勤益科大 Bouuton 節點

Payload :  勤益科大

Hello  Bouuton 節點

Payload :  hello

MQTT out節點

Server :broker.hivemq.com : 1883

Qos=1  保留:

發行主題 :  alex9ufo/esp32/hello

MQTT in節點

Server :broker.hivemq.com : 1883

Qos=1  保留:

發行主題 : alex9ufo/esp32/hello

Text 節點

Label : 訂閱主題 :

Value format{{msg.payload}}

Layout: 上中

 

Node-Red程式

[{"id":"5985ccd980cadbc0","type":"mqtt in","z":"67d337ef020161d4","name":"node-red/out","topic":"alex9ufo/node-red/out","qos":"1","datatype":"auto-detect","broker":"841df58d.ee5e98","nl":false,"rap":true,"rh":0,"inputs":0,"x":150,"y":320,"wires":[["7d50813717d9c144","29cfb54d20b988ba"]]},{"id":"7d50813717d9c144","type":"function","z":"67d337ef020161d4","name":"function LED on ,off","func":"var onoff=msg.payload;\n\nif (onoff==\"on\")\n{\n    msg.payload=true;\n}\nif (onoff==\"off\")\n{\n    msg.payload=false;\n}  \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":320,"wires":[["ccb103c0fc516c71"]]},{"id":"ccb103c0fc516c71","type":"ui_led","z":"67d337ef020161d4","order":3,"group":"680cff3c5de3a744","width":3,"height":2,"label":"","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"#ff0000","value":"false","valueType":"bool"},{"color":"#008000","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"circle","showGlow":true,"name":"","x":490,"y":320,"wires":[]},{"id":"cfd2998590e660dd","type":"ui_button","z":"67d337ef020161d4","name":"","group":"680cff3c5de3a744","order":9,"width":3,"height":1,"passthru":false,"label":"ON","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"on","payloadType":"str","topic":"topic","topicType":"msg","x":130,"y":240,"wires":[["3cbd0b17930c8655"]]},{"id":"5da71322cb4f139e","type":"ui_button","z":"67d337ef020161d4","name":"","group":"680cff3c5de3a744","order":11,"width":3,"height":1,"passthru":false,"label":"OFF","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"off","payloadType":"str","topic":"topic","topicType":"msg","x":130,"y":280,"wires":[["3cbd0b17930c8655"]]},{"id":"3cbd0b17930c8655","type":"mqtt out","z":"67d337ef020161d4","name":"node-red/out","topic":"alex9ufo/node-red/out","qos":"1","retain":"true","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"841df58d.ee5e98","x":310,"y":260,"wires":[]},{"id":"18f3c0d36c1ff134","type":"ui_button","z":"67d337ef020161d4","name":"","group":"680cff3c5de3a744","order":14,"width":3,"height":1,"passthru":false,"label":"hello","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"hello","payloadType":"str","topic":"topic","topicType":"msg","x":130,"y":440,"wires":[["e3c069f1897ee572"]]},{"id":"e3c069f1897ee572","type":"mqtt out","z":"67d337ef020161d4","name":"esp32/hello","topic":"alex9ufo/esp32/hello","qos":"1","retain":"true","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"841df58d.ee5e98","x":310,"y":440,"wires":[]},{"id":"3e679a331c7d78a1","type":"mqtt in","z":"67d337ef020161d4","name":"esp32/hello","topic":"alex9ufo/esp32/hello","qos":"1","datatype":"auto-detect","broker":"841df58d.ee5e98","nl":false,"rap":true,"rh":0,"inputs":0,"x":150,"y":500,"wires":[["a59845502a7ca7e7","998d7a289c204070"]]},{"id":"a59845502a7ca7e7","type":"ui_text","z":"67d337ef020161d4","group":"680cff3c5de3a744","order":8,"width":0,"height":0,"name":"","label":"訂閱主題 : ","format":"{{msg.payload}}","layout":"row-center","className":"","x":350,"y":500,"wires":[]},{"id":"1336ba3046dc85e9","type":"ui_button","z":"67d337ef020161d4","name":"","group":"680cff3c5de3a744","order":12,"width":3,"height":1,"passthru":false,"label":"勤益科大","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"勤益科大","payloadType":"str","topic":"topic","topicType":"msg","x":140,"y":400,"wires":[["e3c069f1897ee572"]]},{"id":"29cfb54d20b988ba","type":"ui_audio","z":"67d337ef020161d4","name":"","group":"680cff3c5de3a744","voice":"Microsoft Yating - Chinese (Traditional, Taiwan)","always":"","x":300,"y":360,"wires":[]},{"id":"998d7a289c204070","type":"ui_audio","z":"67d337ef020161d4","name":"","group":"680cff3c5de3a744","voice":"Microsoft Yating - Chinese (Traditional, Taiwan)","always":"","x":340,"y":540,"wires":[]},{"id":"841df58d.ee5e98","type":"mqtt-broker","name":"","broker":"broker.hivemq.com","port":"1883","clientid":"","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"680cff3c5de3a744","type":"ui_group","name":"LED ON OFF","tab":"68b2e080d17dd8ac","order":2,"disp":true,"width":7,"collapse":false,"className":""},{"id":"68b2e080d17dd8ac","type":"ui_tab","name":"LED","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...