2019-10 RFID 的Node-RED 程式
https://fred.sensetecnic.com/ login 後
UI介面
Flow JSON Source code
[
{
"id": "2d47eef0.900f42",
"type": "mqtt in",
"z": "ffc58342.9a11a",
"name": "MQTT",
"topic": "alex9ufo/outTopic/RFID/json",
"qos": "2",
"datatype": "auto",
"broker": "2071d72e.140ab8",
"x": 70,
"y": 140,
"wires": [
[
"b9e1ec7e.cc9cc",
"bf67a08b.b2a68",
"55ca9b3a.9c81d4",
"c5afe5e9.5ad358",
"c96e6202.92078"
]
]
},
{
"id": "5462a273.a2881c",
"type": "mqtt out",
"z": "ffc58342.9a11a",
"name": "",
"topic": "alex9ufo/inTopic",
"qos": "1",
"retain": "false",
"broker": "2071d72e.140ab8",
"x": 620,
"y": 640,
"wires": []
},
{
"id": "7210fc16.f90714",
"type": "ui_button",
"z": "ffc58342.9a11a",
"name": "",
"group": "54d05f53.b0203",
"order": 0,
"width": "6",
"height": "3",
"passthru": false,
"label": "ON_LED",
"color": "white",
"bgcolor": "",
"icon": "fa-circle",
"payload": "#on",
"payloadType": "str",
"topic": "",
"x": 120,
"y": 640,
"wires": [
[
"5462a273.a2881c",
"c59da6c1.964988",
"6aff5eb4.80e34",
"a07016e7.c17288"
]
]
},
{
"id": "d720fbe2.ce4c48",
"type": "ui_button",
"z": "ffc58342.9a11a",
"name": "",
"group": "54d05f53.b0203",
"order": 0,
"width": "6",
"height": "3",
"passthru": false,
"label": "off_LED",
"color": "black",
"bgcolor": "",
"icon": "fa-circle-o",
"payload": "#off",
"payloadType": "str",
"topic": "",
"x": 120,
"y": 740,
"wires": [
[
"5462a273.a2881c",
"c59da6c1.964988",
"a07016e7.c17288",
"6aff5eb4.80e34"
]
]
},
{
"id": "c59da6c1.964988",
"type": "debug",
"z": "ffc58342.9a11a",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 610,
"y": 700,
"wires": []
},
{
"id": "433f36a3.c18698",
"type": "ui_button",
"z": "ffc58342.9a11a",
"name": "",
"group": "54d05f53.b0203",
"order": 0,
"width": "6",
"height": "3",
"passthru": false,
"label": "flash_LED",
"color": "black",
"bgcolor": "",
"icon": "fa-circle-o",
"payload": "#flash",
"payloadType": "str",
"topic": "",
"x": 130,
"y": 844,
"wires": [
[
"5462a273.a2881c",
"c59da6c1.964988",
"a07016e7.c17288",
"6aff5eb4.80e34"
]
]
},
{
"id": "b9e1ec7e.cc9cc",
"type": "function",
"z": "ffc58342.9a11a",
"name": "json+時分秒",
"func": "var date = new Date();\nvar h = date.getHours();\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": 290,
"y": 80,
"wires": [
[
"fa440e2f.886fe"
]
]
},
{
"id": "bf67a08b.b2a68",
"type": "switch",
"z": "ffc58342.9a11a",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "Alex9ufo",
"vt": "str"
},
{
"t": "cont",
"v": "RaspberryPi",
"vt": "str"
},
{
"t": "empty"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 230,
"y": 240,
"wires": [
[
"c6ace580.8ea748",
"6993da44.cc03c4"
],
[
"c6ace580.8ea748",
"6d930a3c.b46584"
],
[
"c6ace580.8ea748",
"5599f1cd.7c8f1"
]
]
},
{
"id": "c6ace580.8ea748",
"type": "debug",
"z": "ffc58342.9a11a",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 410,
"y": 200,
"wires": []
},
{
"id": "af05ffad.ee06e",
"type": "ui_audio",
"z": "ffc58342.9a11a",
"name": "",
"group": "54d05f53.b0203",
"voice": "en-US",
"always": "",
"x": 860,
"y": 280,
"wires": []
},
{
"id": "9c0f49eb.b0bf28",
"type": "ui_audio",
"z": "ffc58342.9a11a",
"name": "",
"group": "54d05f53.b0203",
"voice": "en-US",
"always": "",
"x": 600,
"y": 860,
"wires": []
},
{
"id": "6aff5eb4.80e34",
"type": "function",
"z": "ffc58342.9a11a",
"name": "Format timestamp",
"func": "var date = new Date();\nvar h = date.getHours();\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": 410,
"y": 784,
"wires": [
[
"3ad5ba77.41a4b6",
"1dc14634.65675a"
]
]
},
{
"id": "725b1f09.e48b4",
"type": "debug",
"z": "ffc58342.9a11a",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 430,
"y": 420,
"wires": []
},
{
"id": "a19b9172.de1d7",
"type": "inject",
"z": "ffc58342.9a11a",
"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": 190,
"y": 520,
"wires": [
[
"54029654.b8a198"
]
]
},
{
"id": "a07016e7.c17288",
"type": "ui_text_input",
"z": "ffc58342.9a11a",
"name": "",
"label": "",
"group": "54d05f53.b0203",
"order": 9,
"width": "12",
"height": "2",
"passthru": true,
"mode": "text",
"delay": "0",
"topic": "",
"x": 420,
"y": 844,
"wires": [
[
"9c0f49eb.b0bf28",
"6390cc85.26f324"
]
]
},
{
"id": "3ad5ba77.41a4b6",
"type": "debug",
"z": "ffc58342.9a11a",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 610,
"y": 740,
"wires": []
},
{
"id": "451c29c0.2e74b8",
"type": "ui_text_input",
"z": "ffc58342.9a11a",
"name": "",
"label": "",
"group": "54d05f53.b0203",
"order": 9,
"width": "12",
"height": "2",
"passthru": true,
"mode": "text",
"delay": "0",
"topic": "",
"x": 640,
"y": 280,
"wires": [
[
"af05ffad.ee06e",
"cfe51360.8999a"
]
]
},
{
"id": "cfe51360.8999a",
"type": "delay",
"z": "ffc58342.9a11a",
"name": "",
"pauseType": "delay",
"timeout": "80",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 650,
"y": 360,
"wires": [
[
"ee308ec9.a5b22"
]
]
},
{
"id": "ee308ec9.a5b22",
"type": "function",
"z": "ffc58342.9a11a",
"name": "Check Text",
"func": "text=msg.payload;\nif(text !== \"\"){\n msg.payload = \"\";\n return msg;\n}",
"outputs": 1,
"noerr": 0,
"x": 810,
"y": 360,
"wires": [
[
"451c29c0.2e74b8"
]
]
},
{
"id": "6390cc85.26f324",
"type": "delay",
"z": "ffc58342.9a11a",
"name": "",
"pauseType": "delay",
"timeout": "80",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 350,
"y": 924,
"wires": [
[
"ea0f8ccf.7501"
]
]
},
{
"id": "ea0f8ccf.7501",
"type": "function",
"z": "ffc58342.9a11a",
"name": "Check Text",
"func": "text=msg.payload;\nif(text !== \"\"){\n msg.payload = \"\";\n return msg;\n}",
"outputs": 1,
"noerr": 0,
"x": 510,
"y": 924,
"wires": [
[
"a07016e7.c17288"
]
]
},
{
"id": "1bd05325.82dedd",
"type": "ui_button",
"z": "ffc58342.9a11a",
"name": "",
"group": "54d05f53.b0203",
"order": 0,
"width": "12",
"height": "2",
"passthru": false,
"label": "Testing......",
"color": "white",
"bgcolor": "",
"icon": "fa-circle",
"payload": "Testing",
"payloadType": "str",
"topic": "",
"x": 410,
"y": 320,
"wires": [
[
"451c29c0.2e74b8"
]
]
},
{
"id": "f655720f.1f54a",
"type": "ui_template",
"z": "ffc58342.9a11a",
"group": "54d05f53.b0203",
"name": "",
"order": 0,
"width": "15",
"height": "10",
"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,
"templateScope": "local",
"x": 620,
"y": 460,
"wires": [
[]
]
},
{
"id": "fa440e2f.886fe",
"type": "ui_text",
"z": "ffc58342.9a11a",
"group": "54d05f53.b0203",
"order": 0,
"width": 0,
"height": 0,
"name": "",
"label": "MQTT_send_Message",
"format": "{{msg.payload}}",
"layout": "row-center",
"x": 500,
"y": 80,
"wires": []
},
{
"id": "49b4b28c.01dc7c",
"type": "function",
"z": "ffc58342.9a11a",
"name": "INSERT",
"func": "msg.topic = \"INSERT INTO RFIDtable (id,currenttime, uidname) VALUES (?,?,?)\";\n\n\nvar date = new Date();\n\nvar h = date.getHours();\n\nvar m = date.getMinutes();\n\nvar s = date.getSeconds();\n\nif(h<10)\n{\n \n h = '0'+h;\n\n}\n\nif(m<10)\n{\n \n m = '0' + m;\n\n}\n\nif(s<10)\n{\n \n s = '0' + s;\n\n}\n\nvar hms= h + ':' + m + ':' + s ;\nvar id= Date.now() ;\n\nmsg.payload = [id ,hms, msg.payload];\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 220,
"y": 420,
"wires": [
[
"725b1f09.e48b4",
"54029654.b8a198"
]
]
},
{
"id": "5599f1cd.7c8f1",
"type": "function",
"z": "ffc58342.9a11a",
"name": "不合法卡片",
"func": "msg.payload = 'illegal Card'\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 410,
"y": 360,
"wires": [
[
"451c29c0.2e74b8"
]
]
},
{
"id": "261a3e75.48cc22",
"type": "inject",
"z": "ffc58342.9a11a",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 240,
"y": 360,
"wires": [
[
"5599f1cd.7c8f1"
]
]
},
{
"id": "6d930a3c.b46584",
"type": "function",
"z": "ffc58342.9a11a",
"name": "RaspberryPi卡片",
"func": "msg.payload = 'RaspberryPi Card'\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 430,
"y": 280,
"wires": [
[
"451c29c0.2e74b8"
]
]
},
{
"id": "6993da44.cc03c4",
"type": "function",
"z": "ffc58342.9a11a",
"name": "Alex9ufo卡片",
"func": "msg.payload = 'Alex9ufo Card'\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 410,
"y": 240,
"wires": [
[
"451c29c0.2e74b8"
]
]
},
{
"id": "1dc14634.65675a",
"type": "function",
"z": "ffc58342.9a11a",
"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": 610,
"y": 784,
"wires": [
[
"c81e0778.d12438"
]
]
},
{
"id": "c81e0778.d12438",
"type": "http request",
"z": "ffc58342.9a11a",
"name": "",
"method": "POST",
"ret": "txt",
"url": "https://notify-api.line.me/api/notify",
"tls": "",
"x": 770,
"y": 784,
"wires": [
[
"5dbbac.04c2b454"
]
]
},
{
"id": "5dbbac.04c2b454",
"type": "debug",
"z": "ffc58342.9a11a",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 930,
"y": 784,
"wires": []
},
{
"id": "c96e6202.92078",
"type": "debug",
"z": "ffc58342.9a11a",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 290,
"y": 40,
"wires": []
},
{
"id": "55ca9b3a.9c81d4",
"type": "json",
"z": "ffc58342.9a11a",
"name": "",
"property": "payload",
"action": "str",
"pretty": false,
"x": 90,
"y": 420,
"wires": [
[
"49b4b28c.01dc7c"
]
]
},
{
"id": "64f527f1.3e2be8",
"type": "ui_button",
"z": "ffc58342.9a11a",
"name": "",
"group": "54d05f53.b0203",
"order": 10,
"width": "6",
"height": "3",
"passthru": false,
"label": "View Data",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "SELECT * FROM RFIDtable ORDER BY id DESC LIMIT 100;",
"x": 200,
"y": 600,
"wires": [
[
"54029654.b8a198"
]
]
},
{
"id": "c5afe5e9.5ad358",
"type": "function",
"z": "ffc58342.9a11a",
"name": "Format timestamp",
"func": "var date = new Date();\nvar h = date.getHours();\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": 310,
"y": 140,
"wires": [
[
"9c65de7a.e2341"
]
]
},
{
"id": "9c65de7a.e2341",
"type": "function",
"z": "ffc58342.9a11a",
"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": 490,
"y": 140,
"wires": [
[
"ae2c681d.d46278"
]
]
},
{
"id": "ae2c681d.d46278",
"type": "http request",
"z": "ffc58342.9a11a",
"name": "",
"method": "POST",
"ret": "txt",
"url": "https://notify-api.line.me/api/notify",
"tls": "",
"x": 650,
"y": 140,
"wires": [
[
"6e878b02.808b54"
]
]
},
{
"id": "6e878b02.808b54",
"type": "debug",
"z": "ffc58342.9a11a",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 810,
"y": 140,
"wires": []
},
{
"id": "99e7e8b2.feefd8",
"type": "comment",
"z": "ffc58342.9a11a",
"name": "CREATE TABLE RFIDtable",
"info": "CREATE TABLE RFIDtable( id INT PRIMARY KEY NOT NULL, currenttime TEXT , rfid TEXT)",
"x": 150,
"y": 560,
"wires": []
},
{
"id": "84cf8ee7.da5df",
"type": "ui_button",
"z": "ffc58342.9a11a",
"name": "Alex9ufo",
"group": "54d05f53.b0203",
"order": 2,
"width": "6",
"height": "3",
"passthru": false,
"label": "手動插入測試資料",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "{\"RFIDNo\":\"Alex9ufo測試\"}",
"payloadType": "json",
"topic": "",
"x": 400,
"y": 580,
"wires": [
[
"a549c2f.ef94f4"
]
]
},
{
"id": "a549c2f.ef94f4",
"type": "mqtt out",
"z": "ffc58342.9a11a",
"name": "",
"topic": "alex9ufo/outTopic/RFID/json",
"qos": "",
"retain": "",
"broker": "2071d72e.140ab8",
"x": 620,
"y": 580,
"wires": []
},
{
"id": "5a2e05aa.10724c",
"type": "ui_button",
"z": "ffc58342.9a11a",
"name": "",
"group": "54d05f53.b0203",
"order": 11,
"width": "6",
"height": "3",
"passthru": false,
"label": "建立資料庫(只能執行一次)",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "CREATE TABLE RFIDtable( id INT PRIMARY KEY NOT NULL, currenttime TEXT , uidname TEXT)",
"x": 160,
"y": 460,
"wires": [
[
"54029654.b8a198"
]
]
},
{
"id": "54029654.b8a198",
"type": "litedb",
"z": "ffc58342.9a11a",
"name": "RFID",
"x": 430,
"y": 460,
"wires": [
[
"f655720f.1f54a"
]
]
},
{
"id": "2071d72e.140ab8",
"type": "mqtt-broker",
"broker": "broker.mqtt-dashboard.com",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": 15,
"cleansession": true,
"birthQos": "0",
"willQos": "0"
},
{
"id": "54d05f53.b0203",
"type": "ui_group",
"z": "",
"name": "Control led ESP8266 (ESP32)",
"tab": "e6e7f124.a59e4",
"order": 1,
"disp": true,
"width": "15",
"collapse": false
},
{
"id": "e6e7f124.a59e4",
"type": "ui_tab",
"z": "",
"name": "RFID",
"icon": "dashboard",
"order": 1
}
]
訂閱:
張貼留言 (Atom)
2024_09 作業3 以Node-Red 為主
2024_09 作業3 (以Node-Red 為主 Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker 2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...
-
python pip 不是内部或外部命令 -- 解決方法 要安裝 Pyqt5 1. 首先,開啟命令提示字元。 2. 輸入 pip3 install pyqt5 好像不能執行 ! ! 錯誤顯示 : ‘ pip3 ’ 不是內部或外部命令、可執行的程式或批...
-
課程講義 下載 11/20 1) PPT 下載 + 程式下載 http://www.mediafire.com/file/cru4py7e8pptfda/106%E5%8B%A4%E7%9B%8A2-1.rar 11/27 2) PPT 下載...
-
• 認 識 PreFix、InFix、PostFix PreFix(前序式):* + 1 2 + 3 4 InFix(中序式): (1+2)*(3+4) PostFix(後序式):1 2 + 3 4 + * 後 序式的運算 例如: 運算時由 後序式的...
沒有留言:
張貼留言