2023年7月31日 星期一

實驗 ESP32 RFID /LED Control +Node-Red +Line Notify + Sqlite

 實驗 ESP32 RFID /LED Control  +Node-Red +Line Notify + Sqlite 







[{"id":"84c5b49449614692","type":"ui_button","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","order":27,"width":3,"height":1,"passthru":false,"label":"建立資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"建立資料庫","payloadType":"str","topic":"topic","topicType":"msg","x":110,"y":440,"wires":[["3768d2ceadd97a7b","d594f15371bfe40c"]]},{"id":"382bb5846395bf63","type":"ui_button","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","order":30,"width":5,"height":2,"passthru":false,"label":"檢視資料庫資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"檢視資料","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":760,"wires":[["3cedd51f30721ecf","cdcf3d57ea190a69"]]},{"id":"aa7404213db0d11d","type":"ui_button","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","order":25,"width":3,"height":1,"passthru":false,"label":"刪除所有資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"刪除所有資料","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":1000,"wires":[["3c705fe4671b0305","6c673e8d726be5c8"]]},{"id":"83093d49254c6f9b","type":"sqlite","z":"4911fe2890b9eb92","mydb":"dd7f8134e015a1cb","sqlquery":"msg.topic","sql":"","name":"My_RFID_database","x":560,"y":440,"wires":[["95ccdcecdbbfdbe5","3cedd51f30721ecf"]]},{"id":"3768d2ceadd97a7b","type":"function","z":"4911fe2890b9eb92","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":320,"y":440,"wires":[["83093d49254c6f9b"]]},{"id":"95ccdcecdbbfdbe5","type":"debug","z":"4911fe2890b9eb92","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":440,"wires":[]},{"id":"11dfab3f777eb877","type":"function","z":"4911fe2890b9eb92","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":340,"y":480,"wires":[["aae81142c03dd010","83093d49254c6f9b","0bebf0b047e5d8d3"]]},{"id":"3c705fe4671b0305","type":"function","z":"4911fe2890b9eb92","name":"刪除所有資料","func":"//DELETE from RFIDtable\nmsg.topic = \"DELETE from RFIDtable\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":1000,"wires":[["2cb9e557a52a9515"]]},{"id":"2cb9e557a52a9515","type":"sqlite","z":"4911fe2890b9eb92","mydb":"dd7f8134e015a1cb","sqlquery":"msg.topic","sql":"","name":"My_RFID_database","x":560,"y":1000,"wires":[["b8a94866f235cbdb"]]},{"id":"d1c71010edbe95eb","type":"ui_button","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","order":23,"width":3,"height":1,"passthru":false,"label":"刪除資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"刪除資料庫","payloadType":"str","topic":"topic","topicType":"msg","x":110,"y":1080,"wires":[["93b48cd33a4c46a2","84978357b2b53bc6"]]},{"id":"93b48cd33a4c46a2","type":"function","z":"4911fe2890b9eb92","name":"刪除資料庫","func":"//DROP TABLE RFIDtable\nmsg.topic = \"DROP TABLE RFIDtable\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":1080,"wires":[["2cb9e557a52a9515"]]},{"id":"d04adada628e0469","type":"ui_template","z":"4911fe2890b9eb92","group":"85b1efd8d6d7c0dd","name":"","order":13,"width":12,"height":8,"format":"<table style=\"width:100%\">\n  <tr>\n    <th>idex</th> \n    <th>database_id</th>\n    <th>UID </th>\n    <th>Date</th>\n    <th>Times</th>\n  </tr>\n  \n  <tr ng-repeat=\"x in msg.payload | limitTo:50\">\n    <td>{{$index}}</td>\n    <td>{{msg.payload[$index].id}}</td>\n    <td>{{msg.payload[$index].uidname}}</td>\n    <td>{{msg.payload[$index].currentdate}}</td>\n    <td>{{msg.payload[$index].currenttime}}</td>\n  </tr>\n</table>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":980,"y":1160,"wires":[[]]},{"id":"b8a94866f235cbdb","type":"debug","z":"4911fe2890b9eb92","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":1000,"wires":[]},{"id":"3cedd51f30721ecf","type":"function","z":"4911fe2890b9eb92","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":580,"y":760,"wires":[["25abe838fe89cb80"]]},{"id":"25abe838fe89cb80","type":"sqlite","z":"4911fe2890b9eb92","mydb":"dd7f8134e015a1cb","sqlquery":"msg.topic","sql":"","name":"My_RFID_database","x":800.9005737304688,"y":893.5454711914062,"wires":[["d04adada628e0469"]]},{"id":"6bc6d7272a647e6e","type":"function","z":"4911fe2890b9eb92","name":"SELECT ALL","func":"var del_idtemp=msg.payload;\nflow.set(\"idtemp\", del_idtemp);\n\nmsg.topic = \"SELECT * FROM RFIDtable \";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":920,"wires":[["2cb9e557a52a9515","3d4ba3e708e02d20"]]},{"id":"e875e8fb94eb76c8","type":"function","z":"4911fe2890b9eb92","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":320,"y":820,"wires":[["4499ff1983ec4751"]]},{"id":"cf119a4f01b67f0e","type":"ui_numeric","z":"4911fe2890b9eb92","name":"","label":"刪除的database_id","tooltip":"","group":"85b1efd8d6d7c0dd","order":26,"width":3,"height":1,"wrap":false,"passthru":true,"topic":"topic","topicType":"msg","format":"{{value}}","min":"1","max":"100","step":1,"className":"","x":130,"y":920,"wires":[["6bc6d7272a647e6e","6c673e8d726be5c8"]]},{"id":"4499ff1983ec4751","type":"sqlite","z":"4911fe2890b9eb92","mydb":"dd7f8134e015a1cb","sqlquery":"msg.topic","sql":"DELETE FROM dhtreadings WHERE id =  VALUES ($theid)","name":"My_RFID_database","x":520,"y":820,"wires":[["3cedd51f30721ecf"]]},{"id":"eb9a84fdf9433c0b","type":"ui_button","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","order":24,"width":3,"height":1,"passthru":false,"label":"刪除一筆資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"刪除一筆資料","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":820,"wires":[["e875e8fb94eb76c8","cdcf3d57ea190a69"]]},{"id":"3d4ba3e708e02d20","type":"debug","z":"4911fe2890b9eb92","name":"debug 130","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":530,"y":920,"wires":[]},{"id":"c1d07a5d7979271a","type":"mqtt in","z":"4911fe2890b9eb92","name":"新增 RFID","topic":"alex9ufo/esp32/RFID","qos":"2","datatype":"auto-detect","broker":"841df58d.ee5e98","nl":false,"rap":true,"rh":0,"inputs":0,"x":100,"y":480,"wires":[["6b70e1b922fbb8f1"]]},{"id":"aae81142c03dd010","type":"debug","z":"4911fe2890b9eb92","name":"debug 131","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":480,"wires":[]},{"id":"8f7d650eafc7c493","type":"ui_text_input","z":"4911fe2890b9eb92","name":"","label":"新增一筆資料","tooltip":"","group":"85b1efd8d6d7c0dd","order":28,"width":3,"height":1,"passthru":true,"mode":"text","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":340,"y":560,"wires":[[]]},{"id":"9dcbc409eb4b3470","type":"ui_audio","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":520,"y":640,"wires":[]},{"id":"d329d88b9649595f","type":"function","z":"4911fe2890b9eb92","name":"function ","func":"var temp= msg.payload;\nmsg.payload= \"新增一筆資料\" + temp;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":600,"wires":[["9dcbc409eb4b3470","0d33954ed3e764cd"]]},{"id":"cdcf3d57ea190a69","type":"ui_audio","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":320,"y":780,"wires":[]},{"id":"d594f15371bfe40c","type":"ui_audio","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":280,"y":400,"wires":[]},{"id":"f92e5ee564a88937","type":"function","z":"4911fe2890b9eb92","name":"function 50","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":350,"y":1160,"wires":[["4f36c7681231859f","ae7ee34d0d2ecc71"]]},{"id":"c94a37b67d2a3106","type":"ui_button","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","order":17,"width":3,"height":1,"passthru":false,"label":"比對資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"比對資料庫","payloadType":"str","topic":"topic","topicType":"msg","x":110,"y":1160,"wires":[["f92e5ee564a88937","84978357b2b53bc6","c9386f3b40cf18d2"]]},{"id":"4f36c7681231859f","type":"sqlite","z":"4911fe2890b9eb92","mydb":"dd7f8134e015a1cb","sqlquery":"msg.topic","sql":"","name":"My_RFID_database","x":740,"y":1160,"wires":[["d04adada628e0469"]]},{"id":"77f09a925ed5d3f8","type":"function","z":"4911fe2890b9eb92","name":"SELECT ALL","func":"var query_uidtemp=msg.payload;\nflow.set(\"uidtemp\", query_uidtemp);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":700,"wires":[["c39ec9a999838412","3ea049f45947cf06","ac1fc48e834a543c"]]},{"id":"5b36f5ddb217c40a","type":"ui_text_input","z":"4911fe2890b9eb92","name":"","label":"手動查詢資料的uidname","tooltip":"","group":"85b1efd8d6d7c0dd","order":19,"width":3,"height":1,"passthru":true,"mode":"text","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":150,"y":700,"wires":[["77f09a925ed5d3f8"]]},{"id":"d0dd4e0382b7fa01","type":"function","z":"4911fe2890b9eb92","name":"function ","func":"var query=msg.payload;\n\nif (query===true)\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":540,"y":1320,"wires":[["b22d526626577d12","042b262a0e889f51"]]},{"id":"f47a3b01381d21dc","type":"ui_switch","z":"4911fe2890b9eb92","name":"","label":"新增模式  /自動比對模式 ","tooltip":"","group":"85b1efd8d6d7c0dd","order":16,"width":"6","height":1,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":330,"y":1320,"wires":[["d0dd4e0382b7fa01"]]},{"id":"b22d526626577d12","type":"debug","z":"4911fe2890b9eb92","name":"debug 132","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":1280,"wires":[]},{"id":"43e0206b5f4878fe","type":"switch","z":"4911fe2890b9eb92","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":130,"y":620,"wires":[["11dfab3f777eb877","8f7d650eafc7c493","d329d88b9649595f","b18f49985b97c40b"],["142f4115dd46079a","8f7d650eafc7c493","eed385d0f4b46046"]]},{"id":"6b70e1b922fbb8f1","type":"function","z":"4911fe2890b9eb92","name":"function ","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":120,"y":540,"wires":[["43e0206b5f4878fe"]]},{"id":"b18f49985b97c40b","type":"debug","z":"4911fe2890b9eb92","name":"debug 133","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":330,"y":520,"wires":[]},{"id":"042b262a0e889f51","type":"ui_audio","z":"4911fe2890b9eb92","name":"","group":"fe68da70e8d7a3c8","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":700,"y":1320,"wires":[]},{"id":"ae7ee34d0d2ecc71","type":"debug","z":"4911fe2890b9eb92","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":1200,"wires":[]},{"id":"c39ec9a999838412","type":"debug","z":"4911fe2890b9eb92","name":"debug 134","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":680,"wires":[]},{"id":"142f4115dd46079a","type":"function","z":"4911fe2890b9eb92","name":"function","func":"\nvar a= flow.get(\"uid_temp\");\nmsg.payload=a;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":640,"wires":[["77f09a925ed5d3f8","9dcbc409eb4b3470"]]},{"id":"3ea049f45947cf06","type":"ui_text","z":"4911fe2890b9eb92","group":"85b1efd8d6d7c0dd","order":31,"width":6,"height":1,"name":"","label":"自動感應RFID查詢的uid","format":"{{msg.payload}}","layout":"row-left","className":"","x":770,"y":600,"wires":[]},{"id":"ac1fc48e834a543c","type":"link out","z":"4911fe2890b9eb92","name":"link out 12","mode":"link","links":[],"x":695,"y":720,"wires":[]},{"id":"11126d920e4fa323","type":"link in","z":"4911fe2890b9eb92","name":"link in 14","links":["eed385d0f4b46046","f316a7347a7ff85a"],"x":235,"y":1200,"wires":[["f92e5ee564a88937"]]},{"id":"718af4ae09a1e283","type":"function","z":"4911fe2890b9eb92","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":460,"y":1420,"wires":[["c27120970394efe4","5f08cc434a7f4a65"]]},{"id":"c27120970394efe4","type":"sqlite","z":"4911fe2890b9eb92","mydb":"dd7f8134e015a1cb","sqlquery":"msg.topic","sql":"","name":"My_RFID_database","x":660,"y":1420,"wires":[["f785d6c52481bd32"]]},{"id":"f785d6c52481bd32","type":"function","z":"4911fe2890b9eb92","name":"function ","func":"var num=msg.payload[0].總共有幾筆資料;\nmsg.payload=num;\nreturn msg; \n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":1460,"wires":[["e3f4f6848ab41b16","3e425575de8b29e7","38cbe35979c84ef2"]]},{"id":"379a5ed11d9969ec","type":"ui_text","z":"4911fe2890b9eb92","group":"85b1efd8d6d7c0dd","order":21,"width":4,"height":1,"name":"","label":"查詢結果","format":"<font face='arial'><font size=3><font color={{fcolor}}>{{msg.payload}}","layout":"row-left","className":"","x":1140,"y":1480,"wires":[]},{"id":"01074a1557922882","type":"ui_text","z":"4911fe2890b9eb92","group":"85b1efd8d6d7c0dd","order":20,"width":4,"height":1,"name":"","label":"查詢結果:筆數","format":"<font face='arial'><font size=6><font color={{fcolor}}>{{msg.payload}}","layout":"row-left","className":"","x":1160,"y":1440,"wires":[]},{"id":"3e8413d5fcd319fd","type":"mqtt in","z":"4911fe2890b9eb92","name":"","topic":"alex9ufo/esp32/Starting","qos":"2","datatype":"auto-detect","broker":"841df58d.ee5e98","nl":false,"rap":true,"rh":0,"inputs":0,"x":140,"y":1560,"wires":[["f06cd8f545d850ad","28bec2583fd63be8","bba8d9cf66c8696e"]]},{"id":"f06cd8f545d850ad","type":"ui_audio","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":380,"y":1600,"wires":[]},{"id":"28bec2583fd63be8","type":"debug","z":"4911fe2890b9eb92","name":"debug 135","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":390,"y":1560,"wires":[]},{"id":"bba8d9cf66c8696e","type":"change","z":"4911fe2890b9eb92","name":"","rules":[{"t":"set","p":"fcolor","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":1520,"wires":[["38544c6ac54f3327"]]},{"id":"38544c6ac54f3327","type":"ui_text","z":"4911fe2890b9eb92","group":"85b1efd8d6d7c0dd","order":22,"width":4,"height":1,"name":"","label":"","format":"<font face='arial'><font size=4><font color={{fcolor}}>{{msg.payload}}","layout":"row-left","className":"","x":570,"y":1520,"wires":[]},{"id":"5f08cc434a7f4a65","type":"debug","z":"4911fe2890b9eb92","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":1380,"wires":[]},{"id":"e3f4f6848ab41b16","type":"change","z":"4911fe2890b9eb92","name":"","rules":[{"t":"set","p":"fcolor","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":1440,"wires":[["01074a1557922882","ef672c1fc731d682"]]},{"id":"15115f73ed8ec3fa","type":"change","z":"4911fe2890b9eb92","name":"","rules":[{"t":"set","p":"fcolor","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":1480,"wires":[["379a5ed11d9969ec"]]},{"id":"c9386f3b40cf18d2","type":"function","z":"4911fe2890b9eb92","name":"function","func":"\nvar a= flow.get(\"uidtemp\");\nmsg.payload=a;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":1420,"wires":[["718af4ae09a1e283"]]},{"id":"eed385d0f4b46046","type":"link out","z":"4911fe2890b9eb92","name":"link out 13","mode":"link","links":["abf37a6bec449339","11126d920e4fa323"],"x":215,"y":660,"wires":[]},{"id":"abf37a6bec449339","type":"link in","z":"4911fe2890b9eb92","name":"link in 15","links":["eed385d0f4b46046","f316a7347a7ff85a"],"x":175,"y":1380,"wires":[["c9386f3b40cf18d2"]]},{"id":"34e0cb821ff0bf43","type":"inject","z":"4911fe2890b9eb92","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"2","topic":"false","payload":"false","payloadType":"str","x":130,"y":1320,"wires":[["f47a3b01381d21dc"]]},{"id":"e125b41c694c4900","type":"ui_audio","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":1140,"y":1520,"wires":[]},{"id":"ef672c1fc731d682","type":"debug","z":"4911fe2890b9eb92","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1130,"y":1400,"wires":[]},{"id":"79c0c38cadb94aa5","type":"delay","z":"4911fe2890b9eb92","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":960,"y":1520,"wires":[["e125b41c694c4900"]]},{"id":"3e425575de8b29e7","type":"function","z":"4911fe2890b9eb92","name":"function ","func":"var n=msg.payload;\nif (n>0)\n    msg.payload='RFID符合';\nelse\n    msg.payload='RFID錯誤';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":1520,"wires":[["79c0c38cadb94aa5","15115f73ed8ec3fa","c9ea048a141c3604"]]},{"id":"26feb9493ff2c2f7","type":"ui_button","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","order":6,"width":2,"height":1,"passthru":false,"label":"LED 開","tooltip":"","color":"white","bgcolor":"","className":"","icon":"fa-circle","payload":"on","payloadType":"str","topic":"","topicType":"str","x":100,"y":80,"wires":[["1a906f690450d437","6ef225bc141c760b","a0a7c0ced976d432"]]},{"id":"a90d0c9936cfe74c","type":"ui_button","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","order":7,"width":2,"height":1,"passthru":false,"label":"LED 關","tooltip":"","color":"black","bgcolor":"","className":"","icon":"fa-circle-o","payload":"off","payloadType":"str","topic":"","topicType":"str","x":100,"y":120,"wires":[["1a906f690450d437","6ef225bc141c760b","a0a7c0ced976d432"]]},{"id":"1a906f690450d437","type":"mqtt out","z":"4911fe2890b9eb92","name":"Control LED","topic":"alex9ufo/esp32/led","qos":"1","retain":"true","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"70940176.2b2d3","x":350,"y":80,"wires":[]},{"id":"10e82a96f9ec2e7b","type":"comment","z":"4911fe2890b9eb92","name":"Node-Red publish 到 HiveMQ Broker  , ESP32訂閱","info":"將 alex9ufo/inTopic 到(publish)HiveMQ Broker \n給 Arduino 訂閱(Subscribe)","x":230,"y":40,"wires":[]},{"id":"6ef225bc141c760b","type":"ui_audio","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","voice":"zh-TW","always":true,"x":340,"y":220,"wires":[]},{"id":"a0a7c0ced976d432","type":"ui_text","z":"4911fe2890b9eb92","group":"85b1efd8d6d7c0dd","order":14,"width":0,"height":0,"name":"","label":"Node-RED發行到MQTT的資料","format":"{{msg.payload}}","layout":"row-left","className":"","x":410,"y":160,"wires":[]},{"id":"8d8868766384608b","type":"ui_audio","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","voice":"en-US","always":"","x":580,"y":320,"wires":[]},{"id":"340bd87e50aa2e0e","type":"mqtt in","z":"4911fe2890b9eb92","name":"LED status ","topic":"alex9ufo/esp32/led_status","qos":"2","datatype":"utf8","broker":"841df58d.ee5e98","nl":false,"rap":true,"rh":0,"inputs":0,"x":100,"y":320,"wires":[["541b74118a464b97"]]},{"id":"80b73d2c5ccb5619","type":"comment","z":"4911fe2890b9eb92","name":"Node-Red  subscribe HiveMQ Broker  , ESP32發行","info":"將 alex9ufo/inTopic 到(publish)HiveMQ Broker \n給 Arduino 訂閱(Subscribe)","x":220,"y":280,"wires":[]},{"id":"b1ba4f6cb851cb26","type":"ui_text","z":"4911fe2890b9eb92","group":"85b1efd8d6d7c0dd","order":15,"width":0,"height":0,"name":"","label":"Node-RED 訂閱MQTT的資料","format":"{{msg.payload}}","layout":"row-left","className":"","x":500,"y":360,"wires":[]},{"id":"fdec2950f8926fda","type":"ui_button","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","order":8,"width":3,"height":1,"passthru":false,"label":"LED 閃爍","tooltip":"","color":"black","bgcolor":"","className":"","icon":"fa-circle-o","payload":"flash","payloadType":"str","topic":"","topicType":"str","x":100,"y":160,"wires":[["1a906f690450d437","a0a7c0ced976d432","6ef225bc141c760b"]]},{"id":"a7944307b8dca79a","type":"ui_button","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","order":9,"width":2,"height":1,"passthru":false,"label":"LED反向","tooltip":"","color":"black","bgcolor":"","className":"","icon":"fa-circle-o","payload":"toggle","payloadType":"str","topic":"","topicType":"str","x":100,"y":200,"wires":[["1a906f690450d437","a0a7c0ced976d432","6ef225bc141c760b"]]},{"id":"2ae7817b65869c18","type":"ui_button","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","order":10,"width":3,"height":1,"passthru":false,"label":"LED 定時5秒","tooltip":"","color":"black","bgcolor":"","className":"","icon":"fa-circle-o","payload":"timer","payloadType":"str","topic":"","topicType":"str","x":110,"y":240,"wires":[["1a906f690450d437","a0a7c0ced976d432","6ef225bc141c760b"]]},{"id":"541b74118a464b97","type":"function","z":"4911fe2890b9eb92","name":"function 51","func":"msg.payload=\" ---ESP32回來資料---\" +msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":270,"y":320,"wires":[["b1ba4f6cb851cb26","4f1db8eb470fbe3d","03b7622dc4f1bd4d"]]},{"id":"4f1db8eb470fbe3d","type":"delay","z":"4911fe2890b9eb92","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":320,"wires":[["8d8868766384608b"]]},{"id":"0d33954ed3e764cd","type":"function","z":"4911fe2890b9eb92","name":"function 52","func":"var myRFID = flow.get('uid_temp');\nmsg.payload=myRFID;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":600,"wires":[["3ea049f45947cf06"]]},{"id":"84978357b2b53bc6","type":"ui_audio","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":320,"y":1120,"wires":[]},{"id":"6c673e8d726be5c8","type":"ui_audio","z":"4911fe2890b9eb92","name":"","group":"85b1efd8d6d7c0dd","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":320,"y":960,"wires":[]},{"id":"38cbe35979c84ef2","type":"debug","z":"4911fe2890b9eb92","name":"debug 136","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":1340,"wires":[]},{"id":"03b7622dc4f1bd4d","type":"function","z":"4911fe2890b9eb92","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":550,"y":260,"wires":[["e0b0e890252a38a2"]]},{"id":"e0b0e890252a38a2","type":"http request","z":"4911fe2890b9eb92","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://notify-api.line.me/api/notify","tls":"","persist":false,"proxy":"","authType":"","x":720,"y":260,"wires":[["eda286b04d95abf8"]]},{"id":"eda286b04d95abf8","type":"debug","z":"4911fe2890b9eb92","name":"debug 137","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":260,"wires":[]},{"id":"e3ba592186b142d4","type":"comment","z":"4911fe2890b9eb92","name":"Line Notify Message ","info":"","x":730,"y":220,"wires":[]},{"id":"0bebf0b047e5d8d3","type":"function","z":"4911fe2890b9eb92","name":"function 53","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":550,"y":400,"wires":[["12ce157bd820e804"]]},{"id":"12ce157bd820e804","type":"function","z":"4911fe2890b9eb92","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":770,"y":400,"wires":[["475c1b0634617f9e"]]},{"id":"475c1b0634617f9e","type":"http request","z":"4911fe2890b9eb92","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://notify-api.line.me/api/notify","tls":"","persist":false,"proxy":"","authType":"","x":920,"y":400,"wires":[["0d05b9f35f70490e"]]},{"id":"0d05b9f35f70490e","type":"debug","z":"4911fe2890b9eb92","name":"debug 138","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1070,"y":400,"wires":[]},{"id":"8a5d960612fd14e5","type":"comment","z":"4911fe2890b9eb92","name":"Line Notify Message ","info":"","x":830,"y":360,"wires":[]},{"id":"e362af0df87936ee","type":"function","z":"4911fe2890b9eb92","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":930,"y":1620,"wires":[["8f1805c88f21ab24"]]},{"id":"576c1847150a48ae","type":"comment","z":"4911fe2890b9eb92","name":"Line Notify Message ","info":"","x":950,"y":1580,"wires":[]},{"id":"8f1805c88f21ab24","type":"http request","z":"4911fe2890b9eb92","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://notify-api.line.me/api/notify","tls":"","persist":false,"proxy":"","authType":"","x":1080,"y":1620,"wires":[["5e5c4bdeadbd2d64"]]},{"id":"5e5c4bdeadbd2d64","type":"debug","z":"4911fe2890b9eb92","name":"debug 139","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1230,"y":1620,"wires":[]},{"id":"c9ea048a141c3604","type":"function","z":"4911fe2890b9eb92","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":740,"y":1620,"wires":[["e362af0df87936ee"]]},{"id":"85b1efd8d6d7c0dd","type":"ui_group","name":"ESP32","tab":"eeb8e179.a47a4","order":2,"disp":true,"width":"13","collapse":false,"className":""},{"id":"dd7f8134e015a1cb","type":"sqlitedb","db":"C:\\Users\\User\\.node-red\\my_2023rfid.db","mode":"RWC"},{"id":"841df58d.ee5e98","type":"mqtt-broker","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":"fe68da70e8d7a3c8","type":"ui_group","name":"2023 RFID Home","tab":"9c33f04edb058032","order":3,"disp":true,"width":"14","collapse":false,"className":""},{"id":"70940176.2b2d3","type":"mqtt-broker","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":"eeb8e179.a47a4","type":"ui_tab","name":"2023 RFID Database","icon":"dashboard","disabled":false,"hidden":false},{"id":"9c33f04edb058032","type":"ui_tab","name":"2023-07 Home","icon":"dashboard","disabled":false,"hidden":false}]

沒有留言:

張貼留言

Messaging API作為替代方案

  LINE超好用功能要沒了!LINE Notify明年3月底終止服務,有什麼替代方案? LINE Notify將於2025年3月31日結束服務,官方建議改用Messaging API作為替代方案。 //CHANNEL_ACCESS_TOKEN = 'Messaging ...