2024年3月24日 星期日

2024產專班 作業2 (模擬 不含ESP32 + MFRC522)

2024產專班 作業2 (模擬 不含ESP32 + MFRC522)

(SQLite的使用)











[{"id":"236480bb7c089087","type":"sqlite","z":"ac79aab3f5f0aea9","mydb":"f5c97c74cc496505","sqlquery":"msg.topic","sql":"","name":"LED_STATUS","x":580,"y":400,"wires":[["c2ed3e0bc69c8bd2"]]},{"id":"f71f044c8c38b060","type":"function","z":"ac79aab3f5f0aea9","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":360,"y":400,"wires":[["236480bb7c089087"]]},{"id":"4478fb3473ef889b","type":"ui_button","z":"ac79aab3f5f0aea9","name":"","group":"473c7f322e2cf823","order":9,"width":3,"height":1,"passthru":false,"label":"建立LED資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"建立資料庫","payloadType":"str","topic":"topic","topicType":"msg","x":140,"y":400,"wires":[["f71f044c8c38b060","7387e694cd0eefc4"]]},{"id":"61d3e5637793ec55","type":"ui_button","z":"ac79aab3f5f0aea9","name":"","group":"473c7f322e2cf823","order":1,"width":2,"height":1,"passthru":false,"label":"ON","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"on","payloadType":"str","topic":"topic","topicType":"msg","x":110,"y":40,"wires":[["ec251833ef00fbd4","09288416d4f17dec"]]},{"id":"aa6fe888009bc131","type":"ui_button","z":"ac79aab3f5f0aea9","name":"","group":"473c7f322e2cf823","order":2,"width":2,"height":1,"passthru":false,"label":"OFF","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"off","payloadType":"str","topic":"topic","topicType":"msg","x":110,"y":80,"wires":[["ec251833ef00fbd4","09288416d4f17dec"]]},{"id":"a9524f3a5fb52f77","type":"ui_button","z":"ac79aab3f5f0aea9","name":"","group":"473c7f322e2cf823","order":4,"width":2,"height":1,"passthru":false,"label":"TIMER","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"timer","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":120,"wires":[["ec251833ef00fbd4","09288416d4f17dec"]]},{"id":"38fde6fe4be74978","type":"ui_button","z":"ac79aab3f5f0aea9","name":"","group":"473c7f322e2cf823","order":5,"width":2,"height":1,"passthru":false,"label":"FLASH","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"flash","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":160,"wires":[["ec251833ef00fbd4","09288416d4f17dec"]]},{"id":"4b5c4c80075c0633","type":"function","z":"ac79aab3f5f0aea9","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":320,"y":260,"wires":[["6a1c0db5fbe1cb58"]]},{"id":"ec251833ef00fbd4","type":"ui_audio","z":"ac79aab3f5f0aea9","name":"","group":"473c7f322e2cf823","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":285,"y":100,"wires":[],"l":false},{"id":"6a1c0db5fbe1cb58","type":"sqlite","z":"ac79aab3f5f0aea9","mydb":"f5c97c74cc496505","sqlquery":"msg.topic","sql":"","name":"LED_STATUS","x":480,"y":260,"wires":[["1919cce7164ddb23","4e4e3c785593b51c"]]},{"id":"c2ed3e0bc69c8bd2","type":"debug","z":"ac79aab3f5f0aea9","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":400,"wires":[]},{"id":"1919cce7164ddb23","type":"debug","z":"ac79aab3f5f0aea9","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":260,"wires":[]},{"id":"de4098dd7f73745e","type":"ui_button","z":"ac79aab3f5f0aea9","name":"","group":"473c7f322e2cf823","order":8,"width":4,"height":1,"passthru":false,"label":"檢視資料庫資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"檢視資料","payloadType":"str","topic":"topic","topicType":"msg","x":140,"y":340,"wires":[["4e4e3c785593b51c","7387e694cd0eefc4"]]},{"id":"4e4e3c785593b51c","type":"function","z":"ac79aab3f5f0aea9","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":440,"y":340,"wires":[["880cafbf4de0804b"]]},{"id":"8c6e3f38b2e6f457","type":"ui_table","z":"ac79aab3f5f0aea9","group":"473c7f322e2cf823","name":"","order":6,"width":10,"height":10,"columns":[],"outputs":0,"cts":false,"x":770,"y":340,"wires":[]},{"id":"880cafbf4de0804b","type":"sqlite","z":"ac79aab3f5f0aea9","mydb":"f5c97c74cc496505","sqlquery":"msg.topic","sql":"","name":"LED_STATUS","x":620,"y":340,"wires":[["8c6e3f38b2e6f457"]]},{"id":"a5d2143b49aa260a","type":"sqlite","z":"ac79aab3f5f0aea9","mydb":"f5c97c74cc496505","sqlquery":"msg.topic","sql":"","name":"LED_STATUS","x":900,"y":460,"wires":[["6a44746b28623421"]]},{"id":"9f50a1b0ab62f7e5","type":"ui_button","z":"ac79aab3f5f0aea9","name":"","group":"473c7f322e2cf823","order":7,"width":3,"height":1,"passthru":false,"label":"刪除所有資料 ","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"刪除所有資料 ","payloadType":"str","topic":"topic","topicType":"msg","x":140,"y":460,"wires":[["2bb2ac72fa415b95","caa82d0279e1a1d8"]]},{"id":"20af563fb6cb3c0e","type":"function","z":"ac79aab3f5f0aea9","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":710,"y":460,"wires":[["a5d2143b49aa260a"]]},{"id":"2bb2ac72fa415b95","type":"ui_audio","z":"ac79aab3f5f0aea9","name":"","group":"473c7f322e2cf823","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":265,"y":520,"wires":[],"l":false},{"id":"caa82d0279e1a1d8","type":"ui_toast","z":"ac79aab3f5f0aea9","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":330,"y":460,"wires":[["49ee7541d15f2584"]]},{"id":"49ee7541d15f2584","type":"function","z":"ac79aab3f5f0aea9","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":500,"y":460,"wires":[["20af563fb6cb3c0e"],[]]},{"id":"7387e694cd0eefc4","type":"ui_audio","z":"ac79aab3f5f0aea9","name":"","group":"473c7f322e2cf823","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":285,"y":360,"wires":[],"l":false},{"id":"6a44746b28623421","type":"link out","z":"ac79aab3f5f0aea9","name":"link out 50","mode":"link","links":["57f2bdb122058e11"],"x":885,"y":400,"wires":[]},{"id":"57f2bdb122058e11","type":"link in","z":"ac79aab3f5f0aea9","name":"link in 45","links":["6a44746b28623421"],"x":955,"y":400,"wires":[["4e4e3c785593b51c"]]},{"id":"09288416d4f17dec","type":"mqtt out","z":"ac79aab3f5f0aea9","name":"Control LED out","topic":"alex9ufo/2024/esp32/led","qos":"1","retain":"true","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"603bb104.d6134","x":320,"y":40,"wires":[]},{"id":"ac299c93cfe10448","type":"mqtt in","z":"ac79aab3f5f0aea9","name":"Control LED in","topic":"alex9ufo/2024/esp32/led","qos":"1","datatype":"auto-detect","broker":"603bb104.d6134","nl":false,"rap":true,"rh":0,"inputs":0,"x":140,"y":260,"wires":[["4b5c4c80075c0633"]]},{"id":"c0a66965f6a9a4b3","type":"comment","z":"ac79aab3f5f0aea9","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":120,"y":660,"wires":[]},{"id":"7a832f0fe6e0c69b","type":"comment","z":"ac79aab3f5f0aea9","name":"資料庫位置 C:\\Users\\User\\.node-red\\2024EX2_1.db","info":"","x":230,"y":700,"wires":[]},{"id":"1327954b0f74913c","type":"ui_button","z":"ac79aab3f5f0aea9","name":"","group":"4f3d3e75e5932a3b","order":4,"width":3,"height":1,"passthru":false,"label":"建立RFID資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"建立資料庫","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":740,"wires":[["12198a2da79201c6","9463b02b4806e080"]]},{"id":"20cbb80ca3c65f2b","type":"ui_button","z":"ac79aab3f5f0aea9","name":"","group":"4f3d3e75e5932a3b","order":5,"width":4,"height":1,"passthru":false,"label":"檢視資料庫資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"檢視資料","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":1380,"wires":[["2462b1c1886c6fc8","8f50f9fb097d04a2","f33c6fc81b0e6244"]]},{"id":"f52c2d9c54fd7508","type":"ui_button","z":"ac79aab3f5f0aea9","name":"","group":"4f3d3e75e5932a3b","order":6,"width":3,"height":1,"passthru":false,"label":"刪除RFID資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"刪除所有資料","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":1460,"wires":[["af9325e50586b378","2462b1c1886c6fc8"]]},{"id":"12198a2da79201c6","type":"function","z":"ac79aab3f5f0aea9","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":340,"y":740,"wires":[["1cc23fb7c25ce5f4"]]},{"id":"6f70896879fcea44","type":"debug","z":"ac79aab3f5f0aea9","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":1020,"wires":[]},{"id":"93299fe23033df17","type":"function","z":"ac79aab3f5f0aea9","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":360,"y":1020,"wires":[["7dc87031d825a8d9","8c607e4cc77003cc"]]},{"id":"01b71de91e22efef","type":"function","z":"ac79aab3f5f0aea9","name":"DROP DATABASE","func":"//DROP RFIDtable\n\nmsg.topic = \"DROP TABLE RFIDtable\" ;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":1480,"wires":[["40e236764c8d7add"]]},{"id":"c23f4b92cd253384","type":"debug","z":"ac79aab3f5f0aea9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1090,"y":1480,"wires":[]},{"id":"f33c6fc81b0e6244","type":"function","z":"ac79aab3f5f0aea9","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":760,"y":1380,"wires":[["6d29311735f67b98","5dc4eea938ee927c"]]},{"id":"b6df90997fe707a2","type":"mqtt in","z":"ac79aab3f5f0aea9","name":"RFID in","topic":"alex9ufo/2024/esp32/RFID","qos":"2","datatype":"auto-detect","broker":"841df58d.ee5e98","nl":false,"rap":true,"rh":0,"inputs":0,"x":90,"y":1100,"wires":[["f8e7813a22f75cbc","db353e5fe23ddc5b"]]},{"id":"b428d4c930aef5bf","type":"ui_audio","z":"ac79aab3f5f0aea9","name":"","group":"4f3d3e75e5932a3b","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":560,"y":1220,"wires":[]},{"id":"2df95ef7d4606d40","type":"function","z":"ac79aab3f5f0aea9","name":"function ","func":"var temp= msg.payload;\nmsg.payload= \"新增一筆資料\" + temp;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":1180,"wires":[["b428d4c930aef5bf","af22fea64ba1a77b","b62f133637c5eeb7"]]},{"id":"2462b1c1886c6fc8","type":"ui_audio","z":"ac79aab3f5f0aea9","name":"","group":"4f3d3e75e5932a3b","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":320,"y":1420,"wires":[]},{"id":"9463b02b4806e080","type":"ui_audio","z":"ac79aab3f5f0aea9","name":"","group":"4f3d3e75e5932a3b","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":300,"y":780,"wires":[]},{"id":"dbc01dfe41180ab8","type":"ui_text","z":"ac79aab3f5f0aea9","group":"4f3d3e75e5932a3b","order":2,"width":8,"height":1,"name":"","label":"自動感應RFID查詢的uid","format":"{{msg.payload}}","layout":"row-left","className":"","x":770,"y":1180,"wires":[]},{"id":"af22fea64ba1a77b","type":"function","z":"ac79aab3f5f0aea9","name":"取得UID號碼","func":"var myRFID = flow.get('uid_temp');\nmsg.payload=myRFID;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":570,"y":1180,"wires":[["dbc01dfe41180ab8"]]},{"id":"7dc87031d825a8d9","type":"function","z":"ac79aab3f5f0aea9","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":560,"y":1080,"wires":[["50cf231253a3b5d5"]]},{"id":"50cf231253a3b5d5","type":"function","z":"ac79aab3f5f0aea9","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":730,"y":1080,"wires":[["3037562ef98920fc"]]},{"id":"3037562ef98920fc","type":"http request","z":"ac79aab3f5f0aea9","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://notify-api.line.me/api/notify","tls":"","persist":false,"proxy":"","authType":"","x":880,"y":1080,"wires":[["be392a66f0ef0b9b"]]},{"id":"be392a66f0ef0b9b","type":"debug","z":"ac79aab3f5f0aea9","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1010,"y":1080,"wires":[]},{"id":"e4cc399bd8117cbb","type":"comment","z":"ac79aab3f5f0aea9","name":"Line Notify Message ","info":"","x":870,"y":1040,"wires":[]},{"id":"24bfd09e8917b9c1","type":"ui_table","z":"ac79aab3f5f0aea9","group":"4f3d3e75e5932a3b","name":"","order":3,"width":10,"height":10,"columns":[],"outputs":0,"cts":false,"x":1070,"y":1380,"wires":[]},{"id":"af9325e50586b378","type":"ui_toast","z":"ac79aab3f5f0aea9","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":310,"y":1480,"wires":[["b58d2b9ac12387e6"]]},{"id":"b58d2b9ac12387e6","type":"function","z":"ac79aab3f5f0aea9","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":480,"y":1480,"wires":[["01b71de91e22efef"],[]]},{"id":"feec86a778f5652b","type":"link out","z":"ac79aab3f5f0aea9","name":"link out 52","mode":"link","links":["bc18b32b609aae41"],"x":645,"y":980,"wires":[]},{"id":"8f50f9fb097d04a2","type":"ui_toast","z":"ac79aab3f5f0aea9","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":330,"y":1340,"wires":[]},{"id":"a7c2d7a8bf831555","type":"debug","z":"ac79aab3f5f0aea9","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":740,"wires":[]},{"id":"f8e7813a22f75cbc","type":"ui_toast","z":"ac79aab3f5f0aea9","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":210,"y":1160,"wires":[]},{"id":"1cc23fb7c25ce5f4","type":"sqlite","z":"ac79aab3f5f0aea9","mydb":"f87c808cc786ae80","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":520,"y":740,"wires":[["a7c2d7a8bf831555"]]},{"id":"8c607e4cc77003cc","type":"sqlite","z":"ac79aab3f5f0aea9","mydb":"f87c808cc786ae80","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":540,"y":1020,"wires":[["feec86a778f5652b","6f70896879fcea44"]]},{"id":"6d29311735f67b98","type":"sqlite","z":"ac79aab3f5f0aea9","mydb":"f87c808cc786ae80","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":900,"y":1380,"wires":[["24bfd09e8917b9c1"]]},{"id":"40e236764c8d7add","type":"sqlite","z":"ac79aab3f5f0aea9","mydb":"f87c808cc786ae80","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":860,"y":1480,"wires":[["c23f4b92cd253384","f33c6fc81b0e6244"]]},{"id":"5dc4eea938ee927c","type":"debug","z":"ac79aab3f5f0aea9","name":"debug 275","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":1340,"wires":[]},{"id":"b64194965971f3d2","type":"ui_button","z":"ac79aab3f5f0aea9","name":"","group":"4f3d3e75e5932a3b","order":1,"width":2,"height":1,"passthru":false,"label":"送RFID UID","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"on","payloadType":"str","topic":"topic","topicType":"msg","x":110,"y":860,"wires":[["4ef4af8e051d6137"]]},{"id":"4ef4af8e051d6137","type":"function","z":"ac79aab3f5f0aea9","name":"模擬RFID UID","func":"const MIN = 0;\nconst MAX = 255;\nvar hex_v=0;\n//The maximum is exclusive and the minimum is inclusive\nfunction getRandomInt(min = MIN, max = MAX) {\n    min = Math.ceil(min);\n    max = Math.floor(max);\n    return Math.floor(Math.random() * (max - min)) + min;\n}\n\nfunction decToHex(dec) {\n  hex_v= dec.toString(16);\n  if(hex_v<10)\n  {\n    hex_v= '0'+hex_v;\n    }\n    return hex_v;\n}\n\nvar no1=getRandomInt(min = MIN, max = MAX);\nvar no2=getRandomInt(min = MIN, max = MAX);\nvar no3=getRandomInt(min = MIN, max = MAX);\nvar no4=getRandomInt(min = MIN, max = MAX);\nvar no5=getRandomInt(min = MIN, max = MAX);\nvar no6=getRandomInt(min = MIN, max = MAX);\nvar no7=getRandomInt(min = MIN, max = MAX);\nvar no8=getRandomInt(min = MIN, max = MAX);\n\nvar var1=decToHex(no1);\nvar var2=decToHex(no2);\nvar var3=decToHex(no3);\nvar var4=decToHex(no4);\nvar var5=decToHex(no5);\nvar var6=decToHex(no6);\nvar var7=decToHex(no7);\nvar var8=decToHex(no8);\n\nmsg.payload=[var1,var2,var3,var4];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":860,"wires":[["7c8fe2018f922ea0"]]},{"id":"7c8fe2018f922ea0","type":"function","z":"ac79aab3f5f0aea9","name":"整理輸出","func":"var temp=\"\";\nfor (var i = 0; i < msg.payload.length; i++) \n{\n    temp=temp+ \" \" + msg.payload[i];\n    temp=temp.toUpperCase();\n}\nmsg.payload=temp;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":860,"wires":[["6c3d7d984074e9d3","b4e433a75fe7abc8"]]},{"id":"b4e433a75fe7abc8","type":"mqtt out","z":"ac79aab3f5f0aea9","name":"RFID  out","topic":"alex9ufo/2024/esp32/RFID","qos":"1","retain":"true","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"841df58d.ee5e98","x":680,"y":900,"wires":[]},{"id":"6c3d7d984074e9d3","type":"debug","z":"ac79aab3f5f0aea9","name":"debug 276","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":860,"wires":[]},{"id":"b62f133637c5eeb7","type":"ui_toast","z":"ac79aab3f5f0aea9","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":590,"y":1140,"wires":[]},{"id":"bc18b32b609aae41","type":"link in","z":"ac79aab3f5f0aea9","name":"link in 46","links":["609e318ca3262939","feec86a778f5652b","70487decb239f3c4","ce142a687d0b79f1"],"x":655,"y":1340,"wires":[["f33c6fc81b0e6244"]]},{"id":"db353e5fe23ddc5b","type":"function","z":"ac79aab3f5f0aea9","name":"Store UID","func":"flow.set(\"uid_temp\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":240,"y":1100,"wires":[["93299fe23033df17","2df95ef7d4606d40"]]},{"id":"f5c97c74cc496505","type":"sqlitedb","db":"C:\\Users\\User\\.node-red\\2024EX2.db","mode":"RWC"},{"id":"473c7f322e2cf823","type":"ui_group","name":"LED","tab":"83e4ead9f81fa18d","order":1,"disp":true,"width":"10","collapse":false,"className":""},{"id":"603bb104.d6134","type":"mqtt-broker","name":"","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"4f3d3e75e5932a3b","type":"ui_group","name":"RFID","tab":"83e4ead9f81fa18d","order":2,"disp":true,"width":10,"collapse":false,"className":""},{"id":"841df58d.ee5e98","type":"mqtt-broker","name":"","broker":"broker.hivemq.com","port":"1883","clientid":"","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"f87c808cc786ae80","type":"sqlitedb","db":"C:\\Users\\User\\.node-red\\2024EX2_1.db","mode":"RWC"},{"id":"83e4ead9f81fa18d","type":"ui_tab","name":"2024產專作業2(模擬)","icon":"dashboard","order":104,"disabled":false,"hidden":false}]



沒有留言:

張貼留言

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

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