2020年11月1日 星期日

在 https://fred.sensetecnic.com/執行自動連接到WiFi 的 ESP32 , MQTT , Node-RED , Line , LED ,SQLite 實驗2

在 https://fred.sensetecnic.com/執行自動連接到WiFi 的 ESP32 , MQTT , Node-RED , Line , LED ,SQLite 實驗2






Front End for Node-RED (FRED) manages instances of Node-RED for multiple users in the cloud.

UI畫面  https://{username}.fred.sensetecnic.com/api/ui


Node-red 在https://fred.sensetecnic.com/ 上 SQLite不能用需換成litedb

Node-Red  在https://fred.sensetecnic.com程式

載點

http://www.mediafire.com/file/okijfsqahjy7jt4/flows_RFID_FRED_2020-10.json/file

http://www.mediafire.com/file/okijfsqahjy7jt4/flows_RFID_FRED_2020-10.json/file

[

    {

        "id": "7806fba0.6a4ad4",

        "type": "mqtt in",

        "z": "69aafdcf.4ea7e4",

        "name": "RFID MQTT",

        "topic": "alex9ufo/outTopic/RFID/json",

        "qos": "1",

        "datatype": "auto",

        "broker": "70940176.2b2d3",

        "x": 120,

        "y": 120,

        "wires": [

            [

                "56a9dc5d.403144",

                "d093cb7.7c72b38",

                "ad72de4a.631b3",

                "583b93f5.6a85cc"

            ]

        ]

    },

    {

        "id": "e47623.900cf9e",

        "type": "mqtt out",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "topic": "alex9ufo/inTopic/led/led_event",

        "qos": "1",

        "retain": "true",

        "broker": "70940176.2b2d3",

        "x": 420,

        "y": 600,

        "wires": []

    },

    {

        "id": "56a9dc5d.403144",

        "type": "function",

        "z": "69aafdcf.4ea7e4",

        "name": "json+時分秒",

        "func": "var date = new Date();\nvar h = date.getHours()+8;\nvar m = date.getMinutes();\nvar s = date.getSeconds();\nif(h<10){\n    h = '0'+h;\n}\nif(m<10){\n    m = '0' + m;\n}\nif(s<10){\n    s = '0' + s;\n}\nmsg.payload = 'Time:(' + h + ':' + m + ':' + s + ')'+ msg.payload ;\nreturn msg;\n",

        "outputs": 1,

        "noerr": 0,

        "x": 360,

        "y": 80,

        "wires": [

            [

                "5dccccc3.0bc534"

            ]

        ]

    },

    {

        "id": "d093cb7.7c72b38",

        "type": "switch",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "property": "payload",

        "propertyType": "msg",

        "rules": [

            {

                "t": "cont",

                "v": "966aa5f4",

                "vt": "str"

            },

            {

                "t": "cont",

                "v": "7021ed10",

                "vt": "str"

            },

            {

                "t": "cont",

                "v": "96928cf4",

                "vt": "str"

            },

            {

                "t": "cont",

                "v": "b68b19f5",

                "vt": "str"

            },

            {

                "t": "cont",

                "v": "",

                "vt": "str"

            }

        ],

        "checkall": "true",

        "repair": false,

        "outputs": 5,

        "x": 220,

        "y": 200,

        "wires": [

            [

                "db88907f.74feb"

            ],

            [

                "6eb5f7a2.d7f5c8"

            ],

            [

                "eda2ab1b.97f778"

            ],

            [

                "c7d16f00.8ee36"

            ],

            [

                "3503abdd.e85dd4"

            ]

        ]

    },

    {

        "id": "1e8bb48b.3867ab",

        "type": "debug",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "active": false,

        "tosidebar": true,

        "console": false,

        "tostatus": false,

        "complete": "payload",

        "x": 620,

        "y": 180,

        "wires": []

    },

    {

        "id": "c5ce0dac.d34a9",

        "type": "ui_audio",

        "z": "69aafdcf.4ea7e4",

        "name": "播放聲音",

        "group": "92b4e639.d05558",

        "voice": "zh-TW",

        "always": true,

        "x": 930,

        "y": 300,

        "wires": []

    },

    {

        "id": "3058db1.7dac724",

        "type": "function",

        "z": "69aafdcf.4ea7e4",

        "name": "Format timestamp",

        "func": "var date = new Date();\nvar h = date.getHours()+8 ;\nvar m = date.getMinutes();\nvar s = date.getSeconds();\nif(h<10){\n    h = '0'+h;\n}\nif(m<10){\n    m = '0' + m;\n}\nif(s<10){\n    s = '0' + s;\n}\nmsg.payload = msg.payload + ' --> Time:(' + h + ':' + m + ':' + s + ')' ;\n\nreturn msg;",

        "outputs": 1,

        "noerr": 0,

        "x": 440,

        "y": 660,

        "wires": [

            [

                "2c8e84e.286f07c",

                "8515a460.cc1c78"

            ]

        ]

    },

    {

        "id": "2dc0d9d6.e8b476",

        "type": "debug",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "active": false,

        "tosidebar": true,

        "console": false,

        "tostatus": false,

        "complete": "payload",

        "x": 860,

        "y": 360,

        "wires": []

    },

    {

        "id": "99db84f.a858c78",

        "type": "inject",

        "z": "69aafdcf.4ea7e4",

        "name": "CREATE DB",

        "topic": "CREATE TABLE RFIDtable( id INT PRIMARY KEY NOT NULL, currenttime TEXT , uidname TEXT)",

        "payload": "",

        "payloadType": "date",

        "repeat": "",

        "crontab": "",

        "once": false,

        "onceDelay": 0.1,

        "x": 200,

        "y": 460,

        "wires": [

            [

                "1b31a21d.01f34e"

            ]

        ]

    },

    {

        "id": "2c8e84e.286f07c",

        "type": "debug",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "active": true,

        "tosidebar": true,

        "console": false,

        "tostatus": false,

        "complete": "false",

        "x": 660,

        "y": 660,

        "wires": []

    },

    {

        "id": "37514278.d0de5e",

        "type": "ui_text_input",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "label": "",

        "tooltip": "",

        "group": "92b4e639.d05558",

        "order": 9,

        "width": 0,

        "height": 0,

        "passthru": true,

        "mode": "text",

        "delay": "0",

        "topic": "",

        "x": 750,

        "y": 300,

        "wires": [

            [

                "c5ce0dac.d34a9",

                "be01ca44.d2c928"

            ]

        ]

    },

    {

        "id": "f984e998.412de8",

        "type": "ui_button",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "group": "92b4e639.d05558",

        "order": 0,

        "width": "4",

        "height": "1",

        "passthru": false,

        "label": "聲音測試",

        "tooltip": "",

        "color": "white",

        "bgcolor": "orange",

        "icon": "fa-circle",

        "payload": "聲音測試",

        "payloadType": "str",

        "topic": "",

        "x": 750,

        "y": 220,

        "wires": [

            [

                "37514278.d0de5e"

            ]

        ]

    },

    {

        "id": "c57cf217.8d005",

        "type": "ui_template",

        "z": "69aafdcf.4ea7e4",

        "group": "92b4e639.d05558",

        "name": "",

        "order": 0,

        "width": "12",

        "height": "4",

        "format": "<table style=\"width:100%\">\n  <tr>\n    <th>Index</th> \n    <th>Date</th> \n    <th>RFID</th>\n  </tr>\n  <tr ng-repeat=\"x in msg.payload | limitTo:20\">\n    <td>{{$index}}</td>\n    <td>{{msg.payload[$index].currenttime}}</td>\n    <td>{{msg.payload[$index].uidname}}</td> \n  </tr>\n</table>",

        "storeOutMessages": true,

        "fwdInMessages": true,

        "resendOnRefresh": false,

        "templateScope": "local",

        "x": 650,

        "y": 420,

        "wires": [

            []

        ]

    },

    {

        "id": "5dccccc3.0bc534",

        "type": "ui_text",

        "z": "69aafdcf.4ea7e4",

        "group": "92b4e639.d05558",

        "order": 0,

        "width": 0,

        "height": 0,

        "name": "",

        "label": "MQTT_send_Message",

        "format": "{{msg.payload}}",

        "layout": "row-left",

        "x": 650,

        "y": 80,

        "wires": []

    },

    {

        "id": "8641ba3e.5d4f88",

        "type": "function",

        "z": "69aafdcf.4ea7e4",

        "name": "INSERT",

        "func": "msg.topic = \"INSERT INTO RFIDtable (id,currenttime, uidname) VALUES (?,?,?)\";\n\nvar Today = new Date();\nvar yyyy = Today.getFullYear(); //年\nvar MM = Today.getMonth()+1;    //月\nvar dd = Today.getDate();       //日\nvar h = Today.getHours()+8;       //時\nvar m = Today.getMinutes();     //分\nvar s = Today.getSeconds();     //秒\n\nif(MM<10)\n{\n   MM = '0'+MM;\n}\n\nif(dd<10)\n{\n   dd = '0'+dd;\n}\n\nif(h<10)\n{\n   h = '0'+h;\n}\n\nif(m<10)\n{\n  m = '0' + m;\n}\n\nif(s<10)\n{\n  s = '0' + s;\n}\nvar hms= yyyy + '/'+ MM + '/'+ dd + ' ' + h + ':' + m + ':' + s ;\nvar id= Date.now() ;\nmsg.payload = [id ,hms, msg.payload];\nreturn msg;\n",

        "outputs": 1,

        "noerr": 0,

        "x": 690,

        "y": 360,

        "wires": [

            [

                "2dc0d9d6.e8b476",

                "1b31a21d.01f34e"

            ]

        ]

    },

    {

        "id": "3503abdd.e85dd4",

        "type": "function",

        "z": "69aafdcf.4ea7e4",

        "name": "不合法卡片",

        "func": "var st1 = msg.payload.split('\": \"')[1].substr(0,8);\nvar st2='';\n switch (st1)\n {\n case '966aa5f4':\n     st2 = 'Alex9ufo Car';\n     break;\n case '7021ed10':\n     st2 = 'RaspberryPi Card';\n     break;\n case '96928cf4':\n     st2 = 'Node-red Car';\n     break;\n case 'b68b19f5':\n     st2 = 'VIP Car';\n     break;\n default:\n     st2 = 'illegal Card';\n     break;\n }\n msg.payload=st2;\nreturn msg;\n",

        "outputs": 1,

        "noerr": 0,

        "x": 400,

        "y": 320,

        "wires": [

            [

                "37514278.d0de5e",

                "ceb21e14.c4fa"

            ]

        ]

    },

    {

        "id": "6eb5f7a2.d7f5c8",

        "type": "function",

        "z": "69aafdcf.4ea7e4",

        "name": "RaspberryPi卡片",

        "func": "msg.payload = 'RaspberryPi Card'\nreturn msg;",

        "outputs": 1,

        "noerr": 0,

        "x": 420,

        "y": 200,

        "wires": [

            [

                "1e8bb48b.3867ab"

            ]

        ]

    },

    {

        "id": "db88907f.74feb",

        "type": "function",

        "z": "69aafdcf.4ea7e4",

        "name": "Alex9ufo卡片",

        "func": "msg.payload = 'Alex9ufo Card'\nreturn msg;",

        "outputs": 1,

        "noerr": 0,

        "x": 400,

        "y": 160,

        "wires": [

            [

                "1e8bb48b.3867ab"

            ]

        ]

    },

    {

        "id": "8515a460.cc1c78",

        "type": "function",

        "z": "69aafdcf.4ea7e4",

        "name": "Set Line API ",

        "func": "msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer cEI4hx24xyopKGAArgZcKJNHE1V7KeeIi4Lzny3dDNO'};\nmsg.payload = {\"message\":msg.payload};\nreturn msg;",

        "outputs": 1,

        "noerr": 0,

        "x": 580,

        "y": 700,

        "wires": [

            [

                "e1f3a97e.fb7068"

            ]

        ]

    },

    {

        "id": "e1f3a97e.fb7068",

        "type": "http request",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "method": "POST",

        "ret": "txt",

        "url": "https://notify-api.line.me/api/notify",

        "tls": "",

        "x": 730,

        "y": 700,

        "wires": [

            [

                "6989741b.750d1c"

            ]

        ]

    },

    {

        "id": "6989741b.750d1c",

        "type": "debug",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "active": true,

        "tosidebar": true,

        "console": false,

        "tostatus": false,

        "complete": "false",

        "x": 850,

        "y": 750,

        "wires": []

    },

    {

        "id": "ad72de4a.631b3",

        "type": "debug",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "active": true,

        "tosidebar": true,

        "console": false,

        "tostatus": false,

        "complete": "false",

        "x": 320,

        "y": 40,

        "wires": []

    },

    {

        "id": "ceb21e14.c4fa",

        "type": "json",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "property": "payload",

        "action": "str",

        "pretty": false,

        "x": 560,

        "y": 360,

        "wires": [

            [

                "8641ba3e.5d4f88"

            ]

        ]

    },

    {

        "id": "63224002.6240d",

        "type": "ui_button",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "group": "92b4e639.d05558",

        "order": 10,

        "width": "4",

        "height": "1",

        "passthru": false,

        "label": "檢視RFID資料庫",

        "tooltip": "",

        "color": "",

        "bgcolor": "",

        "icon": "",

        "payload": "檢視資料庫",

        "payloadType": "str",

        "topic": "SELECT * FROM RFIDtable ORDER BY  id  DESC LIMIT 100;",

        "x": 190,

        "y": 420,

        "wires": [

            [

                "395247df.63a4f8",

                "1b31a21d.01f34e"

            ]

        ]

    },

    {

        "id": "b33d563d.a78098",

        "type": "comment",

        "z": "69aafdcf.4ea7e4",

        "name": "CREATE TABLE RFIDtable",

        "info": "CREATE TABLE RFIDtable( id INT PRIMARY KEY NOT NULL, currenttime TEXT , rfid TEXT)",

        "x": 180,

        "y": 520,

        "wires": []

    },

    {

        "id": "be7f7b3d.192968",

        "type": "ui_button",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "group": "92b4e639.d05558",

        "order": 11,

        "width": "4",

        "height": "1",

        "passthru": false,

        "label": "建立資料庫(只能執行一次)",

        "tooltip": "",

        "color": "",

        "bgcolor": " purple",

        "icon": "",

        "payload": "",

        "payloadType": "str",

        "topic": "CREATE TABLE RFIDtable( id INT PRIMARY KEY NOT NULL, currenttime TEXT , uidname TEXT)",

        "x": 220,

        "y": 380,

        "wires": [

            [

                "1b31a21d.01f34e"

            ]

        ]

    },

    {

        "id": "4b53c05e.6e419",

        "type": "ui_button",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "group": "92b4e639.d05558",

        "order": 0,

        "width": "4",

        "height": "1",

        "passthru": false,

        "label": "LED 開",

        "tooltip": "",

        "color": "white",

        "bgcolor": "",

        "icon": "fa-circle",

        "payload": "ON",

        "payloadType": "str",

        "topic": "",

        "x": 110,

        "y": 560,

        "wires": [

            [

                "e47623.900cf9e",

                "3058db1.7dac724",

                "9779af7a.7d832"

            ]

        ]

    },

    {

        "id": "d6225e46.471ce",

        "type": "ui_button",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "group": "92b4e639.d05558",

        "order": 0,

        "width": "4",

        "height": "1",

        "passthru": false,

        "label": "LED 關",

        "tooltip": "",

        "color": "black",

        "bgcolor": "",

        "icon": "fa-circle-o",

        "payload": "OFF",

        "payloadType": "str",

        "topic": "",

        "x": 110,

        "y": 600,

        "wires": [

            [

                "e47623.900cf9e",

                "3058db1.7dac724",

                "9779af7a.7d832"

            ]

        ]

    },

    {

        "id": "6c8cebe4.8de9f4",

        "type": "ui_button",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "group": "92b4e639.d05558",

        "order": 0,

        "width": "4",

        "height": "1",

        "passthru": false,

        "label": "LED 開關反向",

        "tooltip": "",

        "color": "blue",

        "bgcolor": "",

        "icon": "fa-circle-o",

        "payload": "TOGGLE",

        "payloadType": "str",

        "topic": "",

        "x": 130,

        "y": 680,

        "wires": [

            [

                "e47623.900cf9e",

                "3058db1.7dac724",

                "9779af7a.7d832"

            ]

        ]

    },

    {

        "id": "2d352b30.0a5254",

        "type": "ui_button",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "group": "92b4e639.d05558",

        "order": 0,

        "width": "4",

        "height": "1",

        "passthru": false,

        "label": "LED 閃爍",

        "tooltip": "",

        "color": "blue",

        "bgcolor": "",

        "icon": "fa-circle-o",

        "payload": "FLASH",

        "payloadType": "str",

        "topic": "",

        "x": 110,

        "y": 640,

        "wires": [

            [

                "e47623.900cf9e",

                "3058db1.7dac724",

                "9779af7a.7d832"

            ]

        ]

    },

    {

        "id": "c938fb11.38fd18",

        "type": "ui_button",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "group": "92b4e639.d05558",

        "order": 0,

        "width": "4",

        "height": "1",

        "passthru": false,

        "label": "LED 開5秒鐘",

        "tooltip": "",

        "color": "purple",

        "bgcolor": "",

        "icon": "fa-circle-o",

        "payload": "TIMER",

        "payloadType": "str",

        "topic": "",

        "x": 120,

        "y": 720,

        "wires": [

            [

                "e47623.900cf9e",

                "3058db1.7dac724",

                "9779af7a.7d832"

            ]

        ]

    },

    {

        "id": "6363270f.79a6d8",

        "type": "comment",

        "z": "69aafdcf.4ea7e4",

        "name": "publish 到 HiveMQ Broker ",

        "info": "將 alex9ufo/led/led_event 發行到(publish)HiveMQ Broker \n給 Arduino 訂閱(Subscribe)",

        "x": 340,

        "y": 560,

        "wires": []

    },

    {

        "id": "10b97976.b52737",

        "type": "comment",

        "z": "69aafdcf.4ea7e4",

        "name": "向 HiveMQ Broker 訂閱subscribe",

        "info": "將  Arduino 發行到(publish)HiveMQ Broker alex9ufo/led/led_status \n給 Node-red 或 MQTTB-Box 訂閱(Subscribe)",

        "x": 700,

        "y": 500,

        "wires": []

    },

    {

        "id": "c0939966.d36a48",

        "type": "mqtt in",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "topic": "alex9ufo/led/led_status",

        "qos": "1",

        "datatype": "auto",

        "broker": "603bb104.d6134",

        "x": 710,

        "y": 540,

        "wires": [

            [

                "a2541194.d6068",

                "2c547a4c.d13bc6",

                "bb3b766a.bb79b8",

                "4d04a91d.227938"

            ]

        ]

    },

    {

        "id": "2c547a4c.d13bc6",

        "type": "debug",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "active": false,

        "tosidebar": true,

        "console": false,

        "tostatus": false,

        "complete": "false",

        "x": 940,

        "y": 480,

        "wires": []

    },

    {

        "id": "a2541194.d6068",

        "type": "ui_text",

        "z": "69aafdcf.4ea7e4",

        "group": "92b4e639.d05558",

        "order": 0,

        "width": 0,

        "height": 0,

        "name": "",

        "label": "Node-Red 向MQTT Suscribe Data",

        "format": "{{msg.payload}}",

        "layout": "row-left",

        "x": 1210,

        "y": 500,

        "wires": []

    },

    {

        "id": "bb3b766a.bb79b8",

        "type": "function",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "func": "var st1;\nif (msg.payload === \"ON\") {\n   st1=\"LED開\"; \n} \nelse if (msg.payload === \"OFF\") {\n  st1=\"LED關\";\n}\nelse if (msg.payload === \"FLASH\") {\n  st1=\"LED閃爍\";\n}\nelse if (msg.payload === \"TIMER\") {\n  st1=\"LED開五秒鐘\";\n}\nelse if (msg.payload === \"TOGGLE\") {\n  st1=\"LED ON OFF 交換\";\n}\n\nmsg.payload=st1;\nreturn msg;",

        "outputs": 1,

        "noerr": 0,

        "x": 980,

        "y": 540,

        "wires": [

            [

                "ca38eba6.e4c898",

                "a2541194.d6068",

                "681d9d2a.2d48d4"

            ]

        ]

    },

    {

        "id": "ca38eba6.e4c898",

        "type": "function",

        "z": "69aafdcf.4ea7e4",

        "name": "INSERT",

        "func": "msg.topic = \"INSERT INTO LEDTable (id, time_led, led_status) VALUES (?,?,?)\";\n\nvar Today = new Date();\nvar yyyy = Today.getFullYear(); //年\nvar MM = Today.getMonth()+1;    //月\nvar dd = Today.getDate();       //日\nvar h = Today.getHours()+8;       //時\nvar m = Today.getMinutes();     //分\nvar s = Today.getSeconds();     //秒\n\nif(MM<10)\n{\n   MM = '0'+MM;\n}\n\nif(dd<10)\n{\n   dd = '0'+dd;\n}\n\nif(h<10)\n{\n   h = '0'+h;\n}\n\nif(m<10)\n{\n  m = '0' + m;\n}\n\nif(s<10)\n{\n  s = '0' + s;\n}\n\nvar hms= yyyy + '/'+ MM + '/'+ dd + ' ' + h + ':' + m + ':' + s ;\nvar id= Date.now() ;\nmsg.payload = [id ,hms, msg.payload];\n//msg.payload = [hms, msg.payload];\n\nreturn msg;\n",

        "outputs": 1,

        "noerr": 0,

        "x": 1010,

        "y": 600,

        "wires": [

            [

                "b9c3bfe0.337bc"

            ]

        ]

    },

    {

        "id": "aa58bdb7.0bd8d",

        "type": "debug",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "active": true,

        "tosidebar": true,

        "console": false,

        "tostatus": false,

        "complete": "false",

        "x": 1360,

        "y": 600,

        "wires": []

    },

    {

        "id": "eda2ab1b.97f778",

        "type": "function",

        "z": "69aafdcf.4ea7e4",

        "name": "Node-red卡片",

        "func": "msg.payload = 'Node-red Card'\nreturn msg;",

        "outputs": 1,

        "noerr": 0,

        "x": 410,

        "y": 240,

        "wires": [

            [

                "1e8bb48b.3867ab"

            ]

        ]

    },

    {

        "id": "c7d16f00.8ee36",

        "type": "function",

        "z": "69aafdcf.4ea7e4",

        "name": "VIP卡片",

        "func": "msg.payload = 'VIP Card'\nreturn msg;",

        "outputs": 1,

        "noerr": 0,

        "x": 390,

        "y": 280,

        "wires": [

            [

                "1e8bb48b.3867ab"

            ]

        ]

    },

    {

        "id": "9779af7a.7d832",

        "type": "link out",

        "z": "69aafdcf.4ea7e4",

        "name": "RFID-1",

        "links": [

            "de9f7b1c.9086a8",

            "1a2e6a1f.317c06"

        ],

        "x": 325,

        "y": 760,

        "wires": []

    },

    {

        "id": "de9f7b1c.9086a8",

        "type": "link in",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "links": [

            "9779af7a.7d832"

        ],

        "x": 505,

        "y": 120,

        "wires": [

            [

                "5dccccc3.0bc534"

            ]

        ]

    },

    {

        "id": "42d69a17.1dfec4",

        "type": "link in",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "links": [

            "681d9d2a.2d48d4",

            "395247df.63a4f8"

        ],

        "x": 665,

        "y": 240,

        "wires": [

            [

                "37514278.d0de5e"

            ]

        ]

    },

    {

        "id": "be01ca44.d2c928",

        "type": "debug",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "active": true,

        "tosidebar": true,

        "console": false,

        "tostatus": false,

        "complete": "false",

        "x": 940,

        "y": 260,

        "wires": []

    },

    {

        "id": "681d9d2a.2d48d4",

        "type": "link out",

        "z": "69aafdcf.4ea7e4",

        "name": "RFIF-2",

        "links": [

            "42d69a17.1dfec4",

            "1a2e6a1f.317c06"

        ],

        "x": 1125,

        "y": 540,

        "wires": []

    },

    {

        "id": "395247df.63a4f8",

        "type": "link out",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "links": [

            "42d69a17.1dfec4"

        ],

        "x": 405,

        "y": 480,

        "wires": []

    },

    {

        "id": "9b08e594.f326a8",

        "type": "link in",

        "z": "69aafdcf.4ea7e4",

        "name": "LINE",

        "links": [

            "583b93f5.6a85cc",

            "4d04a91d.227938",

            "d4c722e8.eaf73"

        ],

        "x": 385,

        "y": 740,

        "wires": [

            [

                "3058db1.7dac724"

            ]

        ]

    },

    {

        "id": "583b93f5.6a85cc",

        "type": "link out",

        "z": "69aafdcf.4ea7e4",

        "name": "To LINE",

        "links": [

            "9b08e594.f326a8"

        ],

        "x": 255,

        "y": 140,

        "wires": []

    },

    {

        "id": "4d04a91d.227938",

        "type": "link out",

        "z": "69aafdcf.4ea7e4",

        "name": "TO Line 2",

        "links": [

            "9b08e594.f326a8"

        ],

        "x": 845,

        "y": 600,

        "wires": []

    },

    {

        "id": "1b31a21d.01f34e",

        "type": "litedb",

        "z": "69aafdcf.4ea7e4",

        "name": "rfid.db",

        "x": 470,

        "y": 420,

        "wires": [

            [

                "c57cf217.8d005"

            ]

        ]

    },

    {

        "id": "b9c3bfe0.337bc",

        "type": "litedb",

        "z": "69aafdcf.4ea7e4",

        "name": "control_LED.db",

        "x": 1190,

        "y": 600,

        "wires": [

            [

                "aa58bdb7.0bd8d",

                "d3fdc948.e4a3d8"

            ]

        ]

    },

    {

        "id": "e716d216.beef1",

        "type": "comment",

        "z": "69aafdcf.4ea7e4",

        "name": "UI介面",

        "info": "https://{username}.fred.sensetecnic.com/api/ui",

        "x": 520,

        "y": 40,

        "wires": []

    },

    {

        "id": "d973cca6.0cbc2",

        "type": "inject",

        "z": "69aafdcf.4ea7e4",

        "name": "CREATE DB",

        "topic": "CREATE TABLE  LEDTable(id INT PRIMARY KEY NOT NULL, time_led TEXT NOT NULL, led_status TEXT NOT NULL)",

        "payload": "",

        "payloadType": "date",

        "repeat": "",

        "crontab": "",

        "once": true,

        "onceDelay": 0.1,

        "x": 1020,

        "y": 640,

        "wires": [

            [

                "b9c3bfe0.337bc"

            ]

        ]

    },

    {

        "id": "d3fdc948.e4a3d8",

        "type": "ui_template",

        "z": "69aafdcf.4ea7e4",

        "group": "92b4e639.d05558",

        "name": "",

        "order": 0,

        "width": "12",

        "height": "4",

        "format": "//msg.topic = \"INSERT INTO LED (id, time_led, led_status) VALUES (?,?,?)\";\n\n<table style=\"width:100%\">\n  <tr>\n    <th>Index</th> \n    <th>Time</th> \n    <th>Status</th>\n  </tr>\n  <tr ng-repeat=\"x in msg.payload | limitTo:20\">\n    <td>{{$index}}</td>\n    <td>{{msg.payload[$index].time_led}}</td>\n    <td>{{msg.payload[$index].led_status}}</td> \n  </tr>\n</table>",

        "storeOutMessages": true,

        "fwdInMessages": true,

        "resendOnRefresh": false,

        "templateScope": "local",

        "x": 1360,

        "y": 660,

        "wires": [

            []

        ]

    },

    {

        "id": "4e453678.e4f9b8",

        "type": "ui_button",

        "z": "69aafdcf.4ea7e4",

        "name": "",

        "group": "92b4e639.d05558",

        "order": 10,

        "width": "4",

        "height": "1",

        "passthru": false,

        "label": "檢視LED資料庫",

        "tooltip": "",

        "color": "",

        "bgcolor": "",

        "icon": "",

        "payload": "檢視資料庫",

        "payloadType": "str",

        "topic": "SELECT * FROM LEDTable ORDER BY  id  DESC LIMIT 100;",

        "x": 1030,

        "y": 690,

        "wires": [

            [

                "b9c3bfe0.337bc"

            ]

        ]

    },

    {

        "id": "70940176.2b2d3",

        "type": "mqtt-broker",

        "z": "",

        "name": "",

        "broker": "broker.mqtt-dashboard.com",

        "port": "1883",

        "clientid": "",

        "usetls": false,

        "compatmode": true,

        "keepalive": "15",

        "cleansession": true,

        "birthTopic": "",

        "birthQos": "0",

        "birthPayload": "",

        "closeTopic": "",

        "closePayload": "",

        "willTopic": "",

        "willQos": "0",

        "willPayload": ""

    },

    {

        "id": "92b4e639.d05558",

        "type": "ui_group",

        "z": "",

        "name": "RFID讀取",

        "tab": "a769a2ac.25aff",

        "order": 1,

        "disp": true,

        "width": "15",

        "collapse": false

    },

    {

        "id": "603bb104.d6134",

        "type": "mqtt-broker",

        "z": "",

        "name": "",

        "broker": "broker.mqtt-dashboard.com",

        "port": "1883",

        "clientid": "",

        "usetls": false,

        "compatmode": false,

        "keepalive": "15",

        "cleansession": true,

        "birthTopic": "",

        "birthQos": "0",

        "birthPayload": "",

        "closeTopic": "",

        "closePayload": "",

        "willTopic": "",

        "willQos": "0",

        "willPayload": ""

    },

    {

        "id": "a769a2ac.25aff",

        "type": "ui_tab",

        "z": "",

        "name": "RFID",

        "icon": "dashboard",

        "order": 1

    }

]

Arduino 程式參考前一篇

http://alex9ufoexploer.blogspot.com/2020/11/wifi-esp32-mqtt-node-red-line-led.html

http://www.mediafire.com/file/mblc033eux6h94l/AutoConnectWiFi_ESP32_RFID_MQTT_NODE_RED_LED.ino/file


沒有留言:

張貼留言

2024產專班 作業2 (純模擬)

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) Node-Red 程式 [{"id":"d8886...