作業3 替代方案 WOKWI + Node-Red 免安裝版 RFID 是利用亂數產生器 模擬的UID卡號
方塊圖
RFID 是利用亂數產生器 模擬的UID卡號
Node-Red 免安裝版本 下載點2處 --> 選1 下載
https://sourceforge.net/projects/nodered-portable/
https://www.mediafire.com/file/9umq4u9k4b0gbrk/nodered-portable-v2.1.3-win32-x64.zip/file
下載後放 C:\Users\User\Downloads 解壓縮後
執行 nodered-portable.exe
安裝新的3個 節點 node-red-node-ui-table , node-red-node-sqlite , node-red-node-ui-table
匯入node-red 程式
https://www.mediafire.com/file/etwaqqzgsxp2l2r/1226flows.json/file
[{"id":"918cf07e173c875f","type":"comment","z":"73615127d2928d60","name":"TABLE LEDSTATUS","info":"CREATE TABLE LEDSTATUS (\nid INTEGER,\nSTATUS TEXT,\nDate DATE,\nTime TIME,\nPRIMARY KEY (id)\n);","x":110,"y":40,"wires":[]},{"id":"996c8ad4ef59c633","type":"function","z":"73615127d2928d60","name":"CREATE DATABASE","func":"//CREATE TABLE LEDSTATUS (\n//id INTEGER,\n//STATUS TEXT,\n//Date DATE,\n//Time TIME,\n//PRIMARY KEY (id)\n//);\n//CREATE TABLE LEDSTATUS (id INTEGER,STATUS TEXT,Date DATE,Time TIME,PRIMARY KEY (id));\nmsg.topic = \"CREATE TABLE LEDSTATUS (id INTEGER,STATUS TEXT,Date DATE,Time TIME,PRIMARY KEY (id))\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":120,"wires":[["b17910635e294f7c"]]},{"id":"e8d2d73f9bf95030","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":6,"width":3,"height":1,"passthru":false,"label":"(L)建立資料庫","tooltip":"","color":"","bgcolor":"green","className":"","icon":"","payload":"建立資料庫","payloadType":"str","topic":"topic","topicType":"msg","x":100,"y":120,"wires":[["996c8ad4ef59c633","2b7b379073519443"]]},{"id":"2b7b379073519443","type":"ui_audio","z":"73615127d2928d60","name":"","group":"c809b61ebd9643ba","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":215,"y":80,"wires":[],"l":false},{"id":"b003126f3b443edc","type":"ui_button","z":"73615127d2928d60","name":"","group":"c3321797b4291333","order":1,"width":5,"height":1,"passthru":false,"label":"ON","tooltip":"","color":"","bgcolor":"green","className":"","icon":"","payload":"on","payloadType":"str","topic":"topic","topicType":"msg","x":70,"y":160,"wires":[["09a1dd8f5d34faf5","7bb86359619801b2","1e6398fa42581387","18be5728490793d5"]]},{"id":"6c5bd8d97b809a14","type":"ui_button","z":"73615127d2928d60","name":"","group":"c3321797b4291333","order":2,"width":5,"height":1,"passthru":false,"label":"OFF","tooltip":"","color":"","bgcolor":"green","className":"","icon":"","payload":"off","payloadType":"str","topic":"topic","topicType":"msg","x":70,"y":200,"wires":[["09a1dd8f5d34faf5","7bb86359619801b2","1e6398fa42581387","18be5728490793d5"]]},{"id":"0d9b0e9ae82a2a65","type":"ui_button","z":"73615127d2928d60","name":"","group":"c3321797b4291333","order":3,"width":5,"height":1,"passthru":false,"label":"TOGGLE","tooltip":"","color":"","bgcolor":"green","className":"","icon":"","payload":"toggle","payloadType":"str","topic":"topic","topicType":"msg","x":80,"y":240,"wires":[["09a1dd8f5d34faf5","7bb86359619801b2","1e6398fa42581387","18be5728490793d5"]]},{"id":"d194ef87acb2d2ca","type":"ui_button","z":"73615127d2928d60","name":"","group":"c3321797b4291333","order":4,"width":5,"height":1,"passthru":false,"label":"TIMER","tooltip":"","color":"","bgcolor":"green","className":"","icon":"","payload":"timer","payloadType":"str","topic":"topic","topicType":"msg","x":80,"y":280,"wires":[["09a1dd8f5d34faf5","7bb86359619801b2","1e6398fa42581387","18be5728490793d5"]]},{"id":"e97cd2def4b4d96d","type":"ui_button","z":"73615127d2928d60","name":"","group":"c3321797b4291333","order":5,"width":5,"height":1,"passthru":false,"label":"FLASH","tooltip":"","color":"","bgcolor":"green","className":"","icon":"","payload":"flash","payloadType":"str","topic":"topic","topicType":"msg","x":80,"y":320,"wires":[["7bb86359619801b2","09a1dd8f5d34faf5","1e6398fa42581387","18be5728490793d5"]]},{"id":"7bb86359619801b2","type":"function","z":"73615127d2928d60","name":"INSERT","func":"var Today = new Date();\nvar yyyy = Today.getFullYear(); //年\nvar MM = Today.getMonth()+1; //月\nvar dd = Today.getDate(); //日\nvar h = Today.getHours(); //時\nvar m = Today.getMinutes(); //分\nvar s = Today.getSeconds(); //秒\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 var_date = yyyy+'/'+MM+'/'+dd;\nvar var_time = h+':'+m+':'+s;\n\nvar myLED = msg.payload;\n\n\nmsg.topic = \"INSERT INTO LEDSTATUS ( STATUS , Date , Time ) VALUES ($myLED, $var_date , $var_time ) \" ;\nmsg.payload = [myLED, var_date , var_time ]\nreturn msg;\n\n\n//INSERT INTO LEDSTATUS (\n//id INTEGER,\n//STATUS TEXT,\n//Date DATE,\n//Time TIME,\n//PRIMARY KEY (id)\n//);\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":260,"wires":[["2d36552335dbbc47"]]},{"id":"09a1dd8f5d34faf5","type":"ui_audio","z":"73615127d2928d60","name":"","group":"c809b61ebd9643ba","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":235,"y":220,"wires":[],"l":false},{"id":"2d36552335dbbc47","type":"sqlite","z":"73615127d2928d60","mydb":"a443e97ada0cf14f","sqlquery":"msg.topic","sql":"","name":"LED_STATUS","x":460,"y":260,"wires":[["1c31c0be1d138922","52f4ac663f53fd46"]]},{"id":"090aad33988be6be","type":"debug","z":"73615127d2928d60","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":120,"wires":[]},{"id":"1c31c0be1d138922","type":"debug","z":"73615127d2928d60","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":260,"wires":[]},{"id":"23e05d70d78ba275","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":8,"width":6,"height":1,"passthru":false,"label":"(L)檢視資料庫資料","tooltip":"","color":"","bgcolor":"green","className":"","icon":"","payload":"檢視資料","payloadType":"str","topic":"topic","topicType":"msg","x":110,"y":420,"wires":[["52f4ac663f53fd46","9b3908e249a866aa"]]},{"id":"52f4ac663f53fd46","type":"function","z":"73615127d2928d60","name":"檢視資料","func":"//INSERT INTO LEDSTATUS (\n//id INTEGER,\n//STATUS TEXT,\n//Date DATE,\n//Time TIME,\n//PRIMARY KEY (id)\n//);\n\n//SELECT * FROM LEDSTATUS ORDER BY id DESC LIMIT 50;\n\nmsg.topic = \"SELECT * FROM LEDSTATUS ORDER BY id DESC LIMIT 50\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":420,"wires":[["883d91c472861df7"]]},{"id":"883d91c472861df7","type":"sqlite","z":"73615127d2928d60","mydb":"a443e97ada0cf14f","sqlquery":"msg.topic","sql":"","name":"LED_STATUS","x":500,"y":420,"wires":[["01c9a918fc6f6554"]]},{"id":"7956b4f3123b6630","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":5,"width":3,"height":1,"passthru":false,"label":"(L)刪除資料庫 ","tooltip":"","color":"","bgcolor":"green","className":"","icon":"","payload":"刪除資料庫 ","payloadType":"str","topic":"topic","topicType":"msg","x":100,"y":660,"wires":[["0c6e1a3a79a9bcd5","611f9e9c25be4490"]]},{"id":"a5eb0397080ce5d7","type":"function","z":"73615127d2928d60","name":"DROP DATABASE","func":"//CREATE TABLE LEDSTATUS (\n//id INTEGER,\n//STATUS TEXT,\n//Date DATE,\n//Time TIME,\n//PRIMARY KEY (id)\n//);\n//CREATE TABLE LEDSTATUS (id INTEGER,STATUS TEXT,Date DATE,Time TIME,PRIMARY KEY (id));\nmsg.topic = \"DROP TABLE LEDSTATUS\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":600,"wires":[["86ab46b063723fee"]]},{"id":"86ab46b063723fee","type":"sqlite","z":"73615127d2928d60","mydb":"a443e97ada0cf14f","sqlquery":"msg.topic","sql":"","name":"LED_STATUS","x":720,"y":520,"wires":[["51223e9513a5ae53"]]},{"id":"7556f6279c87a729","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":4,"width":3,"height":1,"passthru":false,"label":"(L)刪除所有資料 ","tooltip":"","color":"","bgcolor":"green","className":"","icon":"","payload":"刪除所有資料 ","payloadType":"str","topic":"topic","topicType":"msg","x":100,"y":560,"wires":[["611f9e9c25be4490","52ed25a914aad28f"]]},{"id":"9283ad4a102217f4","type":"function","z":"73615127d2928d60","name":"DELETE ALL DATA","func":"//CREATE TABLE LEDSTATUS (\n//id INTEGER,\n//STATUS TEXT,\n//Date DATE,\n//Time TIME,\n//PRIMARY KEY (id)\n//);\n//CREATE TABLE LEDSTATUS (id INTEGER,STATUS TEXT,Date DATE,Time TIME,PRIMARY KEY (id));\nmsg.topic = \"DELETE from LEDSTATUS\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":500,"wires":[["86ab46b063723fee"]]},{"id":"0c6e1a3a79a9bcd5","type":"ui_toast","z":"73615127d2928d60","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":290,"y":660,"wires":[["1f9d3d18b9bc77a7"]]},{"id":"1f9d3d18b9bc77a7","type":"function","z":"73615127d2928d60","name":"function 86","func":"var topic=msg.payload;\nif (topic==\"\"){\n return [msg,null];\n \n}\nif (topic==\"Cancel\"){\n return [null,msg];\n \n}\nreturn msg;","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":660,"wires":[["a5eb0397080ce5d7"],[]]},{"id":"611f9e9c25be4490","type":"ui_audio","z":"73615127d2928d60","name":"","group":"c809b61ebd9643ba","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":225,"y":600,"wires":[],"l":false},{"id":"52ed25a914aad28f","type":"ui_toast","z":"73615127d2928d60","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":310,"y":560,"wires":[["00ece397b0653752"]]},{"id":"00ece397b0653752","type":"function","z":"73615127d2928d60","name":"function 87","func":"var topic=msg.payload;\nif (topic==\"\"){\n return [msg,null];\n \n}\nif (topic==\"Cancel\"){\n return [null,msg];\n \n}\nreturn msg;","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":560,"wires":[["9283ad4a102217f4"],[]]},{"id":"9b3908e249a866aa","type":"ui_audio","z":"73615127d2928d60","name":"","group":"c809b61ebd9643ba","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":175,"y":460,"wires":[],"l":false},{"id":"422eb40cd39186e6","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":1,"width":3,"height":1,"passthru":false,"label":"(L)查詢一筆資料","tooltip":"","color":"","bgcolor":"green","className":"","icon":"","payload":"查詢一筆資料","payloadType":"str","topic":"topic","topicType":"msg","x":100,"y":720,"wires":[["611f9e9c25be4490","08ed118b7815ee7a"]]},{"id":"7124b85d13a180cd","type":"function","z":"73615127d2928d60","name":"查詢一筆資料","func":"//\nvar id = msg.payload.id;\nvar s=global.get(\"SEL1\")\nmsg.topic=\"\";\nvar temp=\"\";\n\nif (s==1)\n{\n temp =\"SELECT * FROM LEDSTATUS\";\n temp=temp+\" WHERE id LIKE '\"+ id +\"'\";\n}\nmsg.topic=temp;\nglobal.set(\"SEL1\",0);\n\nreturn msg;\n\n//SELECT * FROM COMPANY WHERE AGE LIKE 'XXX%';\n//INSERT INTO LEDSTATUS (\n//id INTEGER,\n//STATUS TEXT,\n//Date DATE,\n//Time TIME,\n//PRIMARY KEY (id)\n//);\n\n//SELECT * FROM LEDSTATUS ORDER BY id DESC LIMIT 50;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":720,"wires":[["17e032e915dc4950"]]},{"id":"17e032e915dc4950","type":"sqlite","z":"73615127d2928d60","mydb":"a443e97ada0cf14f","sqlquery":"msg.topic","sql":"","name":"LED_STATUS","x":700,"y":640,"wires":[["01c9a918fc6f6554"]]},{"id":"0b8cfb953c4b3ade","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":2,"width":3,"height":1,"passthru":false,"label":"(L)刪除一筆資料","tooltip":"","color":"","bgcolor":"green","className":"","icon":"","payload":"刪除一筆資料","payloadType":"str","topic":"topic","topicType":"msg","x":100,"y":780,"wires":[["4e20b975d1ec6435","3f1426e489453cc7"]]},{"id":"4e20b975d1ec6435","type":"ui_audio","z":"73615127d2928d60","name":"","group":"7b14a6b23895a629","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":235,"y":820,"wires":[],"l":false},{"id":"2b8a956c655b3940","type":"ui_form","z":"73615127d2928d60","name":"","label":"(L)輸入id","group":"cff14d809bf82c4b","order":1,"width":0,"height":0,"options":[{"label":"ID","value":"id","type":"number","required":true,"rows":null}],"formValue":{"id":""},"payload":"","submit":"Submit","cancel":"Cancle","topic":"Form","topicType":"str","splitLayout":false,"className":"","x":500,"y":780,"wires":[["7124b85d13a180cd","9c27b300ac858c6f","e6a9b7f3a55793b7"]]},{"id":"9c27b300ac858c6f","type":"function","z":"73615127d2928d60","name":"刪除一筆資料","func":"//\nvar id = msg.payload.id;\nvar s=global.get(\"SEL2\")\nmsg.topic=\"\";\nvar temp=\"\";\n\nif (s==2)\n{\n temp =\"DELETE FROM LEDSTATUS\";\n temp=temp+\" WHERE id LIKE '\"+ id +\"'\";\n}\n\nmsg.topic=temp;\nglobal.set(\"SEL2\",0)\nreturn msg;\n\n//SELECT * FROM COMPANY WHERE AGE LIKE 'XXX%';\n//INSERT INTO LEDSTATUS (\n//id INTEGER,\n//STATUS TEXT,\n//Date DATE,\n//Time TIME,\n//PRIMARY KEY (id)\n//);\n\n//DELETE FROM COMPANY WHERE ID = 7;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":780,"wires":[["1b1d0ceae4b6d5c3","fb4766230be7e853"]]},{"id":"51223e9513a5ae53","type":"link out","z":"73615127d2928d60","name":"link out 46","mode":"link","links":["828c30adcefcdf3f"],"x":855,"y":520,"wires":[]},{"id":"828c30adcefcdf3f","type":"link in","z":"73615127d2928d60","name":"link in 42","links":["51223e9513a5ae53"],"x":235,"y":460,"wires":[["52f4ac663f53fd46"]]},{"id":"1b1d0ceae4b6d5c3","type":"sqlite","z":"73615127d2928d60","mydb":"a443e97ada0cf14f","sqlquery":"msg.topic","sql":"","name":"LED_STATUS","x":900,"y":780,"wires":[["51223e9513a5ae53"]]},{"id":"eabdf5169767c3ba","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":3,"width":3,"height":1,"passthru":false,"label":"(L)更正一筆資料","tooltip":"","color":"","bgcolor":"green","className":"","icon":"","payload":"更正一筆資料","payloadType":"str","topic":"topic","topicType":"msg","x":100,"y":860,"wires":[["4e20b975d1ec6435","37140a86dcc0603d"]]},{"id":"437a5150b26144b7","type":"comment","z":"73615127d2928d60","name":"UPDATE查詢的WHERE","info":"UPDATE查詢的WHERE子句的基本語法如下:\n\nUPDATE table_name\nSET column1 = value1, column2 = value2...., columnN = valueN\nWHERE [condition];","x":120,"y":900,"wires":[]},{"id":"6c3d91be4b678015","type":"function","z":"73615127d2928d60","name":"更正一筆資料","func":"//\nvar id = global.get(\"ID\");\nvar status = msg.payload.Status;\nvar date = msg.payload.date;\nvar time = msg.payload.time;\n\nvar s=global.get(\"SEL3\")\nmsg.topic=\"\";\nvar temp=\"\";\n\nif (s==3)\n{\n temp =\"update LEDSTATUS set \";\n temp=temp+\" STATUS= '\" + status +\"'\";\n temp=temp+\" , Date= '\" + date +\"'\";\n temp=temp+\" , Time= '\" + time +\"'\";\n temp=temp+\" WHERE id=\" + id;\n \n //msg.topic = \"update LEDSTATUS set ( id , STATUS , Date , Time ) VALUES ($id, $status , $date , $time ) \" ;\n //msg.payload = [id,status,date,time]\n}\nmsg.topic=temp;\n\nreturn msg;\n\n//msg.topic = \"INSERT INTO LEDSTATUS ( STATUS , Date , Time ) VALUES ($myLED, $var_date , $var_time ) \" ;\n//msg.payload = [myLED, var_date , var_time ]\n\n\n//SELECT * FROM COMPANY WHERE AGE LIKE 'XXX%';\n//INSERT INTO LEDSTATUS (\n//id INTEGER,\n//STATUS TEXT,\n//Date DATE,\n//Time TIME,\n//PRIMARY KEY (id)\n//);\n\n//DELETE FROM COMPANY WHERE ID = 7;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":900,"wires":[["1b1d0ceae4b6d5c3","cc38d2b67a458c83"]]},{"id":"08ed118b7815ee7a","type":"function","z":"73615127d2928d60","name":"function flow set1","func":"var s1=1;\nglobal.set(\"SEL1\",s1);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":720,"wires":[["2b8a956c655b3940"]]},{"id":"3f1426e489453cc7","type":"function","z":"73615127d2928d60","name":"function flow set2","func":"var s1=2;\nglobal.set(\"SEL2\",s1);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":780,"wires":[["2b8a956c655b3940"]]},{"id":"37140a86dcc0603d","type":"function","z":"73615127d2928d60","name":"function flow set3","func":"var s1=3;\nglobal.set(\"SEL3\",s1);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":860,"wires":[["2b8a956c655b3940"]]},{"id":"a09b68aa0b49cb0a","type":"ui_form","z":"73615127d2928d60","name":"","label":"(L)更正欄位","group":"91a01f6c080e6b87","order":7,"width":6,"height":1,"options":[{"label":"STATUS","value":"Status","type":"text","required":true,"rows":null},{"label":"DATE","value":"date","type":"text","required":true,"rows":null},{"label":"TIME","value":"time","type":"text","required":true,"rows":null}],"formValue":{"Status":"","date":"","time":""},"payload":"","submit":"Submit","cancel":"Cancle","topic":"Form","topicType":"str","splitLayout":false,"className":"","x":590,"y":900,"wires":[["6c3d91be4b678015"]]},{"id":"fb4766230be7e853","type":"debug","z":"73615127d2928d60","name":"debug 228","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":740,"wires":[]},{"id":"e6a9b7f3a55793b7","type":"function","z":"73615127d2928d60","name":"Store ID資料","func":"//\nvar id = msg.payload.id;\nglobal.set(\"ID\",id)\nreturn msg;\n\n//SELECT * FROM COMPANY WHERE AGE LIKE 'XXX%';\n//INSERT INTO LEDSTATUS (\n//id INTEGER,\n//STATUS TEXT,\n//Date DATE,\n//Time TIME,\n//PRIMARY KEY (id)\n//);\n\n//DELETE FROM COMPANY WHERE ID = 7;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":590,"y":840,"wires":[["a09b68aa0b49cb0a","57be303e7847521d"]]},{"id":"57be303e7847521d","type":"function","z":"73615127d2928d60","name":"查詢一筆資料","func":"//\nvar id = global.get(\"ID\");\nmsg.topic=\"\";\nvar temp=\"\";\ntemp =\"SELECT * FROM LEDSTATUS\";\ntemp=temp+\" WHERE id LIKE '\"+ id +\"'\";\n\nmsg.topic=temp;\n\nreturn msg;\n\n//SELECT * FROM COMPANY WHERE AGE LIKE 'XXX%';\n//INSERT INTO LEDSTATUS (\n//id INTEGER,\n//STATUS TEXT,\n//Date DATE,\n//Time TIME,\n//PRIMARY KEY (id)\n//);\n\n//SELECT * FROM LEDSTATUS ORDER BY id DESC LIMIT 50;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":840,"wires":[["17e032e915dc4950"]]},{"id":"cc38d2b67a458c83","type":"debug","z":"73615127d2928d60","name":"debug 229","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","statusVal":"","statusType":"auto","x":950,"y":900,"wires":[]},{"id":"d242b21d2a0c5cf3","type":"comment","z":"73615127d2928d60","name":"資料庫位置 C:\\Users\\User\\.node-red\\EX2_1.db","info":"","x":420,"y":40,"wires":[]},{"id":"4913133f8d9ad7f1","type":"mqtt in","z":"73615127d2928d60","name":"LED status ","topic":"alex9ufo/esp32/led_status","qos":"2","datatype":"utf8","broker":"70940176.2b2d3","nl":false,"rap":true,"rh":0,"inputs":0,"x":80,"y":1020,"wires":[["c68a40405ebcb374"]]},{"id":"c68a40405ebcb374","type":"function","z":"73615127d2928d60","name":"function ","func":"msg.payload=\" ---ESP32回來資料---\" +msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":260,"y":1020,"wires":[["2102e7039b045250","649acfed70035e85","f802bd1587ed5984"]]},{"id":"2102e7039b045250","type":"function","z":"73615127d2928d60","name":"Set Line API ","func":"msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer A4wwPNh2WqB7dlfeQyyIAwtggn1kfZSI5LkkCdia1gB'};\nmsg.payload = {\"message\":msg.payload};\nreturn msg;\n\n//oR7KdXvK1eobRr2sRRgsl4PMq23DjDlhfUs96SyUBZu","outputs":1,"noerr":0,"x":450,"y":1020,"wires":[["77033780eba9e29d"]]},{"id":"77033780eba9e29d","type":"http request","z":"73615127d2928d60","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://notify-api.line.me/api/notify","tls":"","persist":false,"proxy":"","authType":"","x":620,"y":1020,"wires":[["497d81e527b7c90e"]]},{"id":"497d81e527b7c90e","type":"debug","z":"73615127d2928d60","name":"debug 230","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":1020,"wires":[]},{"id":"fa1c7c77adc7fc9a","type":"comment","z":"73615127d2928d60","name":"Line Notify Message ","info":"","x":470,"y":980,"wires":[]},{"id":"1e6398fa42581387","type":"mqtt out","z":"73615127d2928d60","name":"Control LED","topic":"alex9ufo/esp32/led","qos":"1","retain":"true","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"70940176.2b2d3","x":290,"y":160,"wires":[]},{"id":"adc12a2696f1243f","type":"comment","z":"73615127d2928d60","name":"alex9ufo/esp32/led","info":"","x":350,"y":200,"wires":[]},{"id":"18be5728490793d5","type":"ui_text","z":"73615127d2928d60","group":"c3321797b4291333","order":6,"width":5,"height":1,"name":"","label":"(L)發行到MQTT的資料 : ","format":"{{msg.payload}}","layout":"row-left","className":"","x":330,"y":300,"wires":[]},{"id":"f802bd1587ed5984","type":"ui_text","z":"73615127d2928d60","group":"c3321797b4291333","order":7,"width":5,"height":1,"name":"","label":"(L)訂閱MQTT的資料 : ","format":"{{msg.payload}}","layout":"row-left","className":"","x":480,"y":1100,"wires":[]},{"id":"f215286fd9b8af31","type":"ui_audio","z":"73615127d2928d60","name":"","group":"7b14a6b23895a629","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":"","x":620,"y":1060,"wires":[]},{"id":"649acfed70035e85","type":"delay","z":"73615127d2928d60","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":440,"y":1060,"wires":[["f215286fd9b8af31"]]},{"id":"ab5fed5a867363af","type":"comment","z":"73615127d2928d60","name":"TABLE RFIDtable","info":"\n//CREATE TABLE \"RFIDtable\" (\n//\t\"id\"\tINT NOT NULL,\n// \"uidname\" TEXT,\n// \"currentdate\" DATE, \n// \"currenttime\" TIME\n//\tPRIMARY KEY(\"id\")\n//);\nmsg.topic = \"CREATE TABLE RFIDtable(id INTEGER PRIMARY KEY AUTOINCREMENT, uidname TEXT, currentdate DATE, currenttime TIME)\";\nreturn msg;\n","x":1200,"y":40,"wires":[]},{"id":"d7f62706d93bcb3b","type":"comment","z":"73615127d2928d60","name":"資料庫位置 C:\\Users\\User\\.node-red\\EX2_1.db","info":"","x":1300,"y":80,"wires":[]},{"id":"505a95f68d90462c","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":14,"width":6,"height":1,"passthru":false,"label":"建立資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"建立資料庫","payloadType":"str","topic":"topic","topicType":"msg","x":1190,"y":160,"wires":[["e0a1194ce540d917","3cb83dbd7b63b7cc"]]},{"id":"09b1dfaae1abeb4b","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":15,"width":6,"height":1,"passthru":false,"label":"檢視資料庫資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"檢視資料","payloadType":"str","topic":"topic","topicType":"msg","x":1200,"y":600,"wires":[["93b048d6f27ed952","0ebe58b7cddd89e2","d89e84f03410393e"]]},{"id":"7bb94cdff7895501","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":12,"width":3,"height":1,"passthru":false,"label":"刪除所有資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"刪除所有資料","payloadType":"str","topic":"topic","topicType":"msg","x":1200,"y":860,"wires":[["12017b7a6f3f09bf","230b03329a7ee52f"]]},{"id":"e0a1194ce540d917","type":"function","z":"73615127d2928d60","name":"CREATE DATABASE","func":"\n\n//CREATE TABLE \"RFIDtable\" (\n//\t\"id\"\tINT NOT NULL,\n// \"uidname\" TEXT,\n// \"currentdate\" DATE, \n// \"currenttime\" TIME\n//\tPRIMARY KEY(\"id\")\n//);\nmsg.topic = \"CREATE TABLE RFIDtable(id INTEGER PRIMARY KEY AUTOINCREMENT, uidname TEXT, currentdate DATE, currenttime TIME)\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1380,"y":160,"wires":[["944c5522d93029ba"]]},{"id":"bf0a8d200db86645","type":"debug","z":"73615127d2928d60","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1990,"y":200,"wires":[]},{"id":"2286d19608607f96","type":"function","z":"73615127d2928d60","name":"INSERT","func":"var Today = new Date();\nvar yyyy = Today.getFullYear(); //年\nvar MM = Today.getMonth()+1; //月\nvar dd = Today.getDate(); //日\nvar h = Today.getHours(); //時\nvar m = Today.getMinutes(); //分\nvar s = Today.getSeconds(); //秒\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 var_date = yyyy+'/'+MM+'/'+dd;\nvar var_time = h+':'+m+':'+s;\n\nvar myRFID = flow.get('uid_temp');\n\n\nmsg.topic = \"INSERT INTO RFIDtable ( uidname , currentdate, currenttime ) VALUES ($myRFID, $var_date , $var_time ) \" ;\nmsg.payload = [myRFID, var_date , var_time ]\nreturn msg;\n\n//CREATE TABLE \"RFIDtable\" (\n//\t\"id\"\tINT NOT NULL,\n// \"uidname\" TEXT,\n// \"currentdate\" DATE, \n// \"currenttime\" TIME\n//\tPRIMARY KEY(\"id\")\n//);","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1560,"y":240,"wires":[["2fb8243eea647a1b","72f85902425dafbd"]]},{"id":"2656d096116d25c6","type":"function","z":"73615127d2928d60","name":"刪除所有資料","func":"//DELETE from RFIDtable\nmsg.topic = \"DELETE from RFIDtable\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1660,"y":880,"wires":[["0d13bf0e6e2bc74b"]]},{"id":"f8217cd589c6c216","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":10,"width":3,"height":1,"passthru":false,"label":"刪除資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"刪除資料庫","payloadType":"str","topic":"topic","topicType":"msg","x":1190,"y":960,"wires":[["49059e7b0e7190d2","d3afd68d2d964d74"]]},{"id":"5adc4edd7745e24c","type":"function","z":"73615127d2928d60","name":"刪除資料庫","func":"//DROP TABLE RFIDtable\nmsg.topic = \"DROP TABLE RFIDtable\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1690,"y":960,"wires":[["646767e4d8f496e4"]]},{"id":"166936c5d16d93b2","type":"debug","z":"73615127d2928d60","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1990,"y":940,"wires":[]},{"id":"d89e84f03410393e","type":"function","z":"73615127d2928d60","name":"檢視資料","func":"\n//CREATE TABLE \"RFIDtable\" (\n//\t\"id\"\tINT NOT NULL,\n// \"uidname\" TEXT,\n// \"currentdate\" DATE, \n// \"currenttime\" TIME\n//\tPRIMARY KEY(\"id\")\n//);\n\n//SELECT * FROM RFIDtable ORDER BY id DESC LIMIT 50;\n\nmsg.topic = \"SELECT * FROM RFIDtable ORDER BY id DESC LIMIT 50\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1840,"y":600,"wires":[["a344942e333780f1","1370642ed41f860b"]]},{"id":"b81063492dfd3f99","type":"function","z":"73615127d2928d60","name":"SELECT ALL","func":"var del_idtemp=msg.payload;\nflow.set(\"idtemp\", del_idtemp);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1410,"y":800,"wires":[["e7608bf0d4fe88eb"]]},{"id":"a0c72c6deca9293a","type":"function","z":"73615127d2928d60","name":"確認 刪除","func":"var del_id = flow.get(\"idtemp\");\n\n\nmsg.topic = \"DELETE FROM RFIDtable WHERE id= ($del_id) \" ;\nmsg.payload = [del_id]\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1640,"y":740,"wires":[["d9baa5da3147fe03"]]},{"id":"a6207d2686fba611","type":"ui_numeric","z":"73615127d2928d60","name":"","label":"刪除的database_id","tooltip":"","group":"cff14d809bf82c4b","order":4,"width":5,"height":1,"wrap":true,"passthru":true,"topic":"topic","topicType":"msg","format":"{{value}}","min":"1","max":"1000","step":1,"className":"","x":1210,"y":800,"wires":[["b81063492dfd3f99"]]},{"id":"ed484331a53b854b","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":11,"width":3,"height":1,"passthru":false,"label":"刪除一筆資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"刪除一筆資料","payloadType":"str","topic":"topic","topicType":"msg","x":1200,"y":660,"wires":[["93b048d6f27ed952","e852561d71dd3c8b"]]},{"id":"e7608bf0d4fe88eb","type":"debug","z":"73615127d2928d60","name":"debug 231","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1590,"y":800,"wires":[]},{"id":"8cf5670c9eca31b2","type":"mqtt in","z":"73615127d2928d60","name":"新增 RFID","topic":"alex9ufo/esp32/RFID","qos":"1","datatype":"utf8","broker":"70940176.2b2d3","nl":false,"rap":true,"rh":0,"inputs":0,"x":1140,"y":240,"wires":[["a6f94be6a5358970","85022ed23f46402a"]]},{"id":"64bd852fc03afb17","type":"ui_audio","z":"73615127d2928d60","name":"","group":"6d6480f6bc65f976","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":1640,"y":400,"wires":[]},{"id":"5133ae517d6f6036","type":"function","z":"73615127d2928d60","name":"function ","func":"var temp= msg.payload;\nmsg.payload= \"新增一筆資料\" + temp;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1460,"y":320,"wires":[["64bd852fc03afb17","04c972ed40dd4aa8","386161feb448b294"]]},{"id":"93b048d6f27ed952","type":"ui_audio","z":"73615127d2928d60","name":"","group":"6d6480f6bc65f976","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":1400,"y":640,"wires":[]},{"id":"3cb83dbd7b63b7cc","type":"ui_audio","z":"73615127d2928d60","name":"","group":"6d6480f6bc65f976","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":1340,"y":120,"wires":[]},{"id":"fb6117669e42cc6b","type":"function","z":"73615127d2928d60","name":"比對 function","func":"//SELECT trackid,name FROM \ttracks WHERE name LIKE 'Wild%'\n//Query\n//CREATE TABLE \"RFIDtable\" (\n//\t\"id\"\tINT NOT NULL,\n// \"uidname\" TEXT,\n// \"currentdate\" DATE, \n// \"currenttime\" TIME\n//\tPRIMARY KEY(\"id\")\n//);\n//msg.topic = \"DELETE FROM RFIDtable WHERE id= ($del_id) \" ;\n\nvar query_uid = flow.get(\"uidtemp\");\nmsg.topic = \"SELECT id,uidname , currentdate,currenttime FROM RFIDtable WHERE uidname LIKE ($query_uid) \";\nmsg.payload = [query_uid]\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1430,"y":1040,"wires":[["341fbe2a12961e58"]]},{"id":"af63b0083d8e8eee","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":13,"width":3,"height":1,"passthru":false,"label":"比對資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"比對資料庫","payloadType":"str","topic":"topic","topicType":"msg","x":1190,"y":1040,"wires":[["fb6117669e42cc6b","49059e7b0e7190d2","62f56a4452d57264"]]},{"id":"9424aaa07c070bbc","type":"function","z":"73615127d2928d60","name":"SELECT ALL","func":"var query_uidtemp=msg.payload;\nflow.set(\"uidtemp\", query_uidtemp);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1650,"y":440,"wires":[["b93a945416a9c451","6e5f7740b04b13ff"]]},{"id":"546a30b478747c50","type":"ui_text_input","z":"73615127d2928d60","name":"","label":"手動查詢資料的uidname","tooltip":"","group":"cff14d809bf82c4b","order":3,"width":5,"height":1,"passthru":true,"mode":"text","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":1430,"y":500,"wires":[["9424aaa07c070bbc"]]},{"id":"00fe1108c49c7df5","type":"function","z":"73615127d2928d60","name":"function ","func":"var query=msg.payload;\n\nif (query== '1' )\n msg.payload='Query';\nelse\n msg.payload='NotQuery';\n\nflow.set(\"query_temp\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1640,"y":1460,"wires":[["6ce6c23a73d0250a","95eeab2bb1709078"]]},{"id":"2df79724a0a1fbdd","type":"ui_switch","z":"73615127d2928d60","name":"","label":"新增模式 /自動比對模式 ","tooltip":"","group":"c3321797b4291333","order":9,"width":5,"height":1,"passthru":true,"decouple":"false","topic":"s1","topicType":"str","style":"","onvalue":"1","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","animate":false,"className":"","x":1370,"y":1460,"wires":[["00fe1108c49c7df5","c24f830549cea048","b8b0fc6520b36386"]]},{"id":"6ce6c23a73d0250a","type":"debug","z":"73615127d2928d60","name":"debug 232","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1790,"y":1440,"wires":[]},{"id":"f42bb2388bb28f97","type":"switch","z":"73615127d2928d60","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Create","vt":"str"},{"t":"eq","v":"Query","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1230,"y":360,"wires":[["2286d19608607f96","5133ae517d6f6036"],["917e2d1f6e62dc1a"]]},{"id":"a6f94be6a5358970","type":"function","z":"73615127d2928d60","name":"Query or Insert ","func":"var query = flow.get(\"query_temp\");\n\nflow.set(\"uid_temp\", msg.payload);\n\nif (query==='NotQuery')\n msg.payload='Create'\nelse\n msg.payload='Query'\n \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1200,"y":300,"wires":[["f42bb2388bb28f97"]]},{"id":"95eeab2bb1709078","type":"ui_audio","z":"73615127d2928d60","name":"","group":"6d6480f6bc65f976","voice":"Google US English","always":true,"x":1780,"y":1480,"wires":[]},{"id":"b93a945416a9c451","type":"debug","z":"73615127d2928d60","name":"debug 233","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1850,"y":460,"wires":[]},{"id":"6e5f7740b04b13ff","type":"ui_text","z":"73615127d2928d60","group":"c3321797b4291333","order":13,"width":5,"height":2,"name":"","label":"RFID的uid","format":"{{msg.payload}}","layout":"row-left","className":"","x":1850,"y":360,"wires":[]},{"id":"a2950fb159945309","type":"function","z":"73615127d2928d60","name":"function ","func":"//CREATE TABLE \"RFIDtable\" (\n//\t\"id\"\tINT NOT NULL,\n// \"uidname\" TEXT,\n// \"currentdate\" DATE, \n// \"currenttime\" TIME\n//\tPRIMARY KEY(\"id\")\n//);\n\n//msg.topic = \"INSERT INTO RFIDtable ( uidname , currentdate, currenttime ) VALUES ($myRFID, $var_date , $var_time ) \" ;\n//msg.payload = [myRFID, var_date , var_time ]\n//return msg;\n\n\nvar tmp=msg.payload;\nmsg.topic = \"select count( * ) as 總共有幾筆資料 from RFIDtable where uidname=($tmp)\";\nmsg.payload=[tmp];\nreturn msg;\n\n// select count( * ) as 總共有幾筆資料 from Customers where address='Japan'","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1520,"y":1180,"wires":[["ca359e9886506c1c"]]},{"id":"ffb5d47b46d350be","type":"function","z":"73615127d2928d60","name":"function ","func":"var num=msg.payload[0].總共有幾筆資料;\nmsg.payload=num;\nreturn msg; \n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1800,"y":1180,"wires":[["874764cdeae6ba2c","30c9edc61a728201"]]},{"id":"eab803e29aa7d24d","type":"ui_text","z":"73615127d2928d60","group":"c3321797b4291333","order":12,"width":5,"height":1,"name":"","label":"查詢結果","format":"<font face='arial'><font size=3><font color={{fcolor}}>{{msg.payload}}","layout":"row-left","className":"","x":2140,"y":1240,"wires":[]},{"id":"04294343dbfd3b01","type":"ui_text","z":"73615127d2928d60","group":"c3321797b4291333","order":11,"width":5,"height":1,"name":"","label":"查詢結果:筆數","format":"<font face='arial'><font size=6><font color={{fcolor}}>{{msg.payload}}","layout":"row-left","className":"","x":2160,"y":1180,"wires":[]},{"id":"be160e08fd9ed8a1","type":"mqtt in","z":"73615127d2928d60","name":"","topic":"alex9ufo/esp32/Starting","qos":"2","datatype":"utf8","broker":"6174aa9d3e8c5856","nl":false,"rap":true,"rh":0,"inputs":0,"x":1220,"y":1300,"wires":[["a6130deb5716e7b4","6005610d57299b70"]]},{"id":"a6130deb5716e7b4","type":"ui_audio","z":"73615127d2928d60","name":"","group":"6d6480f6bc65f976","voice":"Google US English","always":false,"x":1420,"y":1340,"wires":[]},{"id":"874764cdeae6ba2c","type":"change","z":"73615127d2928d60","name":"","rules":[{"t":"set","p":"fcolor","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1980,"y":1180,"wires":[["04294343dbfd3b01"]]},{"id":"788d8a18a725fb90","type":"change","z":"73615127d2928d60","name":"","rules":[{"t":"set","p":"fcolor","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1980,"y":1240,"wires":[["eab803e29aa7d24d"]]},{"id":"62f56a4452d57264","type":"function","z":"73615127d2928d60","name":"function","func":"\nvar a= flow.get(\"uidtemp\");\nmsg.payload=a;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1380,"y":1180,"wires":[["a2950fb159945309"]]},{"id":"abf32f23cf712f1d","type":"ui_audio","z":"73615127d2928d60","name":"","group":"6d6480f6bc65f976","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":2140,"y":1280,"wires":[]},{"id":"ae298c92b01b1fc7","type":"delay","z":"73615127d2928d60","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1980,"y":1280,"wires":[["abf32f23cf712f1d"]]},{"id":"30c9edc61a728201","type":"function","z":"73615127d2928d60","name":"function ","func":"var n=msg.payload;\n\nif (n>0)\n msg.payload='RFID符合';\nelse\n msg.payload='RFID錯誤';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1800,"y":1240,"wires":[["ae298c92b01b1fc7","788d8a18a725fb90","d258d76ee69b790f"]]},{"id":"04c972ed40dd4aa8","type":"function","z":"73615127d2928d60","name":"取得UID號碼","func":"var myRFID = flow.get('uid_temp');\nmsg.payload=myRFID;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1650,"y":360,"wires":[["6e5f7740b04b13ff"]]},{"id":"49059e7b0e7190d2","type":"ui_audio","z":"73615127d2928d60","name":"","group":"6d6480f6bc65f976","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":1340,"y":1000,"wires":[]},{"id":"12017b7a6f3f09bf","type":"ui_audio","z":"73615127d2928d60","name":"","group":"6d6480f6bc65f976","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":1400,"y":840,"wires":[]},{"id":"2fb8243eea647a1b","type":"function","z":"73615127d2928d60","name":"增加 日期 時間","func":"var ms1=msg.payload[0];\nvar ms2=msg.payload[1];\nvar ms3=msg.payload[2];\n\nmsg.payload=\"新增一筆:\"+ms1+\", 日期: \"+ms2+\", 時間:\"+ms3;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1720,"y":280,"wires":[["970d2176dc5623ce"]]},{"id":"970d2176dc5623ce","type":"function","z":"73615127d2928d60","name":"Set Line API ","func":"msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer A4wwPNh2WqB7dlfeQyyIAwtggn1kfZSI5LkkCdia1gB'};\nmsg.payload = {\"message\":msg.payload};\nreturn msg;\n\n//oR7KdXvK1eobRr2sRRgsl4PMq23DjDlhfUs96SyUBZu","outputs":1,"noerr":0,"x":1890,"y":280,"wires":[["b28def53eb88ed09"]]},{"id":"b28def53eb88ed09","type":"http request","z":"73615127d2928d60","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://notify-api.line.me/api/notify","tls":"","persist":false,"proxy":"","authType":"","x":2040,"y":280,"wires":[["49e8b59b82eb8ab2"]]},{"id":"49e8b59b82eb8ab2","type":"debug","z":"73615127d2928d60","name":"debug 234","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2190,"y":280,"wires":[]},{"id":"95803adb96d6e149","type":"comment","z":"73615127d2928d60","name":"Line Notify Message ","info":"","x":1910,"y":320,"wires":[]},{"id":"ae2504c7ea0cd724","type":"function","z":"73615127d2928d60","name":"Set Line API ","func":"msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer A4wwPNh2WqB7dlfeQyyIAwtggn1kfZSI5LkkCdia1gB'};\nmsg.payload = {\"message\":msg.payload};\nreturn msg;\n\n//oR7KdXvK1eobRr2sRRgsl4PMq23DjDlhfUs96SyUBZu","outputs":1,"noerr":0,"x":1970,"y":1380,"wires":[["77b88fbea5875ec5"]]},{"id":"4bf60946872021ae","type":"comment","z":"73615127d2928d60","name":"Line Notify Message ","info":"","x":2150,"y":1420,"wires":[]},{"id":"77b88fbea5875ec5","type":"http request","z":"73615127d2928d60","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://notify-api.line.me/api/notify","tls":"","persist":false,"proxy":"","authType":"","x":2120,"y":1380,"wires":[["4ff0a110aaea79fc"]]},{"id":"4ff0a110aaea79fc","type":"debug","z":"73615127d2928d60","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2250,"y":1380,"wires":[]},{"id":"d258d76ee69b790f","type":"function","z":"73615127d2928d60","name":"function","func":"\nvar a= flow.get(\"uidtemp\");\nvar b=msg.payload;\nmsg.payload=a+\"--->\"+b;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1800,"y":1340,"wires":[["ae2504c7ea0cd724","e6883d79d1bdf08b"]]},{"id":"a9e0c525a2e3dcc9","type":"inject","z":"73615127d2928d60","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"0","payloadType":"str","x":1190,"y":1460,"wires":[["2df79724a0a1fbdd"]]},{"id":"c24f830549cea048","type":"change","z":"73615127d2928d60","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"查詢模式","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"新增模式","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1460,"y":1600,"wires":[["053f185f4427c3a6","fac4a9e1d3b1e029"]]},{"id":"053f185f4427c3a6","type":"ui_text_input","z":"73615127d2928d60","name":"","label":"State:","tooltip":"","group":"c3321797b4291333","order":10,"width":5,"height":1,"passthru":true,"mode":"text","delay":300,"topic":"","sendOnBlur":true,"className":"","topicType":"str","x":1630,"y":1620,"wires":[[]]},{"id":"b8b0fc6520b36386","type":"debug","z":"73615127d2928d60","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1630,"y":1520,"wires":[]},{"id":"7a5e07caae2865e5","type":"inject","z":"73615127d2928d60","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":1580,"y":80,"wires":[["15681eab2221f3bb"]]},{"id":"15681eab2221f3bb","type":"function","z":"73615127d2928d60","name":"id SET ","func":"var del_idtemp=1;\nflow.set(\"idtemp\", del_idtemp);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1710,"y":80,"wires":[[]]},{"id":"6005610d57299b70","type":"ui_toast","z":"73615127d2928d60","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":1450,"y":1300,"wires":[]},{"id":"fac4a9e1d3b1e029","type":"ui_toast","z":"73615127d2928d60","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":1670,"y":1580,"wires":[]},{"id":"230b03329a7ee52f","type":"ui_toast","z":"73615127d2928d60","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":1310,"y":900,"wires":[["38b13d567304caf4"]]},{"id":"38b13d567304caf4","type":"function","z":"73615127d2928d60","name":"OK or Cancel","func":"var topic=msg.payload;\nif (topic==\"\"){\n return [msg,null];\n \n}\nif (topic==\"Cancel\"){\n return [null,msg];\n \n}\nreturn msg;","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1480,"y":900,"wires":[["2656d096116d25c6"],[]]},{"id":"d3afd68d2d964d74","type":"ui_toast","z":"73615127d2928d60","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":1350,"y":960,"wires":[["4f920972a0699d38"]]},{"id":"4f920972a0699d38","type":"function","z":"73615127d2928d60","name":"OK or Cancel","func":"var topic=msg.payload;\nif (topic==\"\"){\n return [msg,null];\n \n}\nif (topic==\"Cancel\"){\n return [null,msg];\n \n}\nreturn msg;","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1520,"y":960,"wires":[["5adc4edd7745e24c"],[]]},{"id":"e852561d71dd3c8b","type":"ui_toast","z":"73615127d2928d60","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":1310,"y":740,"wires":[["5ab3443a7dd4860f"]]},{"id":"5ab3443a7dd4860f","type":"function","z":"73615127d2928d60","name":"OK or Cancel","func":"var topic=msg.payload;\nif (topic==\"\"){\n return [msg,null];\n \n}\nif (topic==\"Cancel\"){\n return [null,msg];\n \n}\nreturn msg;","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1480,"y":740,"wires":[["a0c72c6deca9293a"],[]]},{"id":"33d0d7ce768a28cb","type":"link out","z":"73615127d2928d60","name":"link out 47","mode":"link","links":["6b98e5564ae03d0f"],"x":1945,"y":880,"wires":[]},{"id":"6b98e5564ae03d0f","type":"link in","z":"73615127d2928d60","name":"link in 43","links":["33d0d7ce768a28cb","7a7a82223a0579b6","70487decb239f3c4","ce142a687d0b79f1"],"x":1735,"y":560,"wires":[["d89e84f03410393e"]]},{"id":"7a7a82223a0579b6","type":"link out","z":"73615127d2928d60","name":"link out 48","mode":"link","links":["6b98e5564ae03d0f"],"x":1955,"y":240,"wires":[]},{"id":"c9d619bc4c9e82b0","type":"ui_toast","z":"73615127d2928d60","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":2170,"y":1340,"wires":[]},{"id":"0ebe58b7cddd89e2","type":"ui_toast","z":"73615127d2928d60","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":1410,"y":560,"wires":[]},{"id":"386161feb448b294","type":"ui_toast","z":"73615127d2928d60","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":1670,"y":320,"wires":[]},{"id":"e0f896772c6a29e9","type":"debug","z":"73615127d2928d60","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1830,"y":160,"wires":[]},{"id":"917e2d1f6e62dc1a","type":"function","z":"73615127d2928d60","name":"get UID","func":"\nvar a= flow.get(\"uid_temp\");\nmsg.payload=a;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1420,"y":440,"wires":[["9424aaa07c070bbc","a8381fa2caf86f58"]]},{"id":"e6883d79d1bdf08b","type":"function","z":"73615127d2928d60","name":"function","func":"var b=msg.payload;\nmsg.payload=\"Line Notify --->\"+b;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1980,"y":1340,"wires":[["c9d619bc4c9e82b0"]]},{"id":"85022ed23f46402a","type":"ui_toast","z":"73615127d2928d60","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":1350,"y":200,"wires":[]},{"id":"a8381fa2caf86f58","type":"link out","z":"73615127d2928d60","name":"link out 49","mode":"link","links":["220e0157309579ff"],"x":1515,"y":420,"wires":[]},{"id":"220e0157309579ff","type":"link in","z":"73615127d2928d60","name":"link in 44","links":["a8381fa2caf86f58"],"x":1235,"y":1220,"wires":[["62f56a4452d57264"]]},{"id":"226666911bc8d76f","type":"comment","z":"73615127d2928d60","name":"Set Default Value","info":"","x":1580,"y":40,"wires":[]},{"id":"944c5522d93029ba","type":"sqlite","z":"73615127d2928d60","mydb":"9e654a56c788364a","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":1640,"y":160,"wires":[["e0f896772c6a29e9"]]},{"id":"72f85902425dafbd","type":"sqlite","z":"73615127d2928d60","mydb":"9e654a56c788364a","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":1820,"y":240,"wires":[["7a7a82223a0579b6","bf0a8d200db86645"]]},{"id":"a344942e333780f1","type":"sqlite","z":"73615127d2928d60","mydb":"9e654a56c788364a","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":1980,"y":600,"wires":[["bd03d69a80903453"]]},{"id":"d9baa5da3147fe03","type":"sqlite","z":"73615127d2928d60","mydb":"9e654a56c788364a","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":1780,"y":740,"wires":[["d89e84f03410393e"]]},{"id":"0d13bf0e6e2bc74b","type":"sqlite","z":"73615127d2928d60","mydb":"cdc59054c439d191","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":1820,"y":880,"wires":[["166936c5d16d93b2","33d0d7ce768a28cb"]]},{"id":"646767e4d8f496e4","type":"sqlite","z":"73615127d2928d60","mydb":"9e654a56c788364a","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":1840,"y":960,"wires":[["166936c5d16d93b2"]]},{"id":"341fbe2a12961e58","type":"sqlite","z":"73615127d2928d60","mydb":"9e654a56c788364a","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":1820,"y":1040,"wires":[["bd03d69a80903453"]]},{"id":"1370642ed41f860b","type":"debug","z":"73615127d2928d60","name":"debug 235","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1990,"y":560,"wires":[]},{"id":"ca359e9886506c1c","type":"sqlite","z":"73615127d2928d60","mydb":"9e654a56c788364a","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":1660,"y":1180,"wires":[["ffb5d47b46d350be"]]},{"id":"b17910635e294f7c","type":"sqlite","z":"73615127d2928d60","mydb":"a443e97ada0cf14f","sqlquery":"msg.topic","sql":"","name":"LED_STATUS","x":500,"y":120,"wires":[["090aad33988be6be"]]},{"id":"49e3edfa8cca7da7","type":"ui_button","z":"73615127d2928d60","name":"","group":"c3321797b4291333","order":8,"width":0,"height":0,"passthru":false,"label":"RFID區","tooltip":"","color":"","bgcolor":"fuchsia","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":860,"y":140,"wires":[[]]},{"id":"a6aa84630ea8878f","type":"ui_button","z":"73615127d2928d60","name":"","group":"91a01f6c080e6b87","order":9,"width":6,"height":1,"passthru":false,"label":"RFID區","tooltip":"","color":"","bgcolor":"fuchsia","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":860,"y":180,"wires":[[]]},{"id":"0ac14c18b91cfc52","type":"ui_button","z":"73615127d2928d60","name":"","group":"cff14d809bf82c4b","order":2,"width":5,"height":1,"passthru":false,"label":"RFID區","tooltip":"","color":"","bgcolor":"fuchsia","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":860,"y":220,"wires":[[]]},{"id":"01c9a918fc6f6554","type":"ui_table","z":"73615127d2928d60","group":"7b14a6b23895a629","name":"LED 資料庫","order":1,"width":8,"height":14,"columns":[],"outputs":0,"cts":false,"x":790,"y":420,"wires":[]},{"id":"bd03d69a80903453","type":"ui_table","z":"73615127d2928d60","group":"6d6480f6bc65f976","name":"","order":1,"width":8,"height":14,"columns":[],"outputs":0,"cts":false,"x":2150,"y":600,"wires":[]},{"id":"91a01f6c080e6b87","type":"ui_group","name":"資料庫控制區","tab":"23ac83f3538be8bc","order":4,"disp":true,"width":6,"collapse":false,"className":""},{"id":"c809b61ebd9643ba","type":"ui_group","name":"新增","tab":"049e33377872336e","order":2,"disp":true,"width":6,"collapse":false,"className":""},{"id":"c3321797b4291333","type":"ui_group","name":"LED輸入控制區","tab":"23ac83f3538be8bc","order":1,"disp":true,"width":5,"collapse":false,"className":""},{"id":"a443e97ada0cf14f","type":"sqlitedb","db":"EX2_3_LED.db","mode":"RWC"},{"id":"7b14a6b23895a629","type":"ui_group","name":"LED資料顯示區","tab":"23ac83f3538be8bc","order":2,"disp":true,"width":8,"collapse":false,"className":""},{"id":"cff14d809bf82c4b","type":"ui_group","name":"單筆控制輸入區","tab":"23ac83f3538be8bc","order":5,"disp":true,"width":5,"collapse":false,"className":""},{"id":"70940176.2b2d3","type":"mqtt-broker","name":"","broker":"broker.mqttgo.io","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"6d6480f6bc65f976","type":"ui_group","name":"RFID資料顯示區","tab":"23ac83f3538be8bc","order":3,"disp":true,"width":8,"collapse":false,"className":""},{"id":"6174aa9d3e8c5856","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":{},"sessionExpiry":""},{"id":"9e654a56c788364a","type":"sqlitedb","db":"EX2_3RFID.db","mode":"RWC"},{"id":"cdc59054c439d191","type":"sqlitedb","db":"C:\\Users\\User\\.node-red\\EX2_2.db","mode":"RWC"},{"id":"23ac83f3538be8bc","type":"ui_tab","name":"作業2-3","icon":"dashboard","order":91,"disabled":false,"hidden":false},{"id":"049e33377872336e","type":"ui_tab","name":"作業2-1","icon":"dashboard","disabled":false,"hidden":false}]
修改你的line notify 的發行權杖 (3個 set lineAPI function)
msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer A4wwPNh2WqB7dlfeQyyIAwtggn1kfZSI5LkkCdia1gB'};
msg.payload = {"message":msg.payload};
return msg;
A4wwPNh2WqB7dlfeQyyIAwtggn1kfZSI5LkkCdia1gB
改成你的發行權杖
請參考 https://itcgs.tcgs.tc.edu.tw/yute?cid=2307
瀏覽器 打開wokwi.com
註冊 或 新登入
copy 底下程式 到 sketch.ino
SQLite 資料庫
沒有留言:
張貼留言