2024年3月31日 星期日

Node-red workflow that accesses data in Postgres

 

Node-red workflow that accesses data in Postgres








[{"id":"a88d32e7718a6d87","type":"postgres","z":"82c72b84094f383a","postgresdb":"1f17c4cb95c3dc20","name":"EXampleDataBase","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":550,"y":60,"wires":[["889b8287edfa50b0"]]},{"id":"6e67bb4ca0f1c667","type":"function","z":"82c72b84094f383a","name":"function  ","func":"msg.payload = `CREATE TABLE SQLusers(\n    user_id serial PRIMARY KEY,\n    name  TEXT,\n    age INTEGER,\n    country TEXT\n)`\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":60,"wires":[["a88d32e7718a6d87"]]},{"id":"889b8287edfa50b0","type":"debug","z":"82c72b84094f383a","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":60,"wires":[]},{"id":"07b63f8f7b2d50e8","type":"postgres","z":"82c72b84094f383a","postgresdb":"1f17c4cb95c3dc20","name":"EXampleDataBase","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":750,"y":280,"wires":[["75a8d8d72fa4cf76","189946ae6106a006"]]},{"id":"f8ecac28d7c68e9e","type":"function","z":"82c72b84094f383a","name":"function   Add db ","func":"msg.payload = `INSERT INTO SQLusers(name, age, country)\nVALUES (\n '${msg.payload.name}',\n '${msg.payload.age}', \n '${msg.payload.counrty}')\n returning *\n`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":280,"wires":[["07b63f8f7b2d50e8","d746e83afd4fb8d4"]]},{"id":"75a8d8d72fa4cf76","type":"debug","z":"82c72b84094f383a","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":930,"y":280,"wires":[]},{"id":"550336c689e343c3","type":"inject","z":"82c72b84094f383a","name":"SELECT","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":340,"wires":[["9c9e65c71da30a4e"]]},{"id":"1383d31dfed255e2","type":"inject","z":"82c72b84094f383a","name":"DELETE","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":500,"wires":[["1c07298c15531bd0"]]},{"id":"ed18c5ff0b796b9d","type":"inject","z":"82c72b84094f383a","name":"DROP TABLE","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"DROP TABLE LEDSTATUS","payload":"","payloadType":"date","x":150,"y":600,"wires":[["6a4d4b4432f8dfb6"]]},{"id":"074877409dc11f16","type":"inject","z":"82c72b84094f383a","name":"View Records","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":660,"wires":[["01b19c4e5720c7ee"]]},{"id":"703e53c1c5ccbb6c","type":"ui_template","z":"82c72b84094f383a","group":"a7f7734f2e8432de","name":"UI Table","order":1,"width":6,"height":6,"format":"<table style=\"width:100%\">\n  <tr>\n    <th>user_id</th> \n    <th>name</th> \n    <th>age</th>     \n    <th>country</th>\n  </tr>\n  <tr ng-repeat=\"x in msg.payload | limitTo:20\">\n    <td>{{msg.payload[$index].user_id}}</td>\n    <td>{{msg.payload[$index].name}}</td> \n    <td>{{msg.payload[$index].age}}</td>\n    <td>{{msg.payload[$index].country}}</td>  \n  </tr>\n</table>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":660,"y":660,"wires":[["c188bd4001cbf8aa"]]},{"id":"c24149be7975129c","type":"inject","z":"82c72b84094f383a","name":"CREATE","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":80,"wires":[["6e67bb4ca0f1c667"]]},{"id":"dc380219c6ad1e52","type":"inject","z":"82c72b84094f383a","name":"INSERT","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":280,"wires":[["6d1dde0e8dc69e4e"]]},{"id":"6d1dde0e8dc69e4e","type":"function","z":"82c72b84094f383a","name":"function ","func":"\nmsg.payload={\n    name: 'Alex',\n    age: 50,\n    counrty: '大里'\n}\n\nreturn msg;\n\n//msg.payload = `INSERT INTO users(name, age, country)\n//VALUES (\n// '${msg.payload.name}',\n// '${msg.payload.age}', \n// '${msg.payload.counrty}')\n// returning *\n// `\n//return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":280,"wires":[["f8ecac28d7c68e9e","2f2b13465b51f650"]]},{"id":"d746e83afd4fb8d4","type":"debug","z":"82c72b84094f383a","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":240,"wires":[]},{"id":"2f2b13465b51f650","type":"debug","z":"82c72b84094f383a","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":430,"y":220,"wires":[]},{"id":"9c9e65c71da30a4e","type":"function","z":"82c72b84094f383a","name":"Select","func":"msg.payload = `SELECT * FROM SQLusers `\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":270,"y":340,"wires":[["3b9f8156b761430b","cacb9953be31ce2e"]]},{"id":"3b9f8156b761430b","type":"debug","z":"82c72b84094f383a","name":"debug  ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":450,"y":380,"wires":[]},{"id":"cacb9953be31ce2e","type":"postgres","z":"82c72b84094f383a","postgresdb":"1f17c4cb95c3dc20","name":"EXampleDataBase","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":490,"y":340,"wires":[["88fee6ba4797e2a1"]]},{"id":"88fee6ba4797e2a1","type":"debug","z":"82c72b84094f383a","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":340,"wires":[]},{"id":"2bc5919c9b56f68e","type":"postgres","z":"82c72b84094f383a","postgresdb":"1f17c4cb95c3dc20","name":"EXampleDataBase","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":490,"y":660,"wires":[["703e53c1c5ccbb6c","06acda8cfb11609f"]]},{"id":"1c07298c15531bd0","type":"function","z":"82c72b84094f383a","name":"function ","func":"var id=msg.payload;\n\nmsg.payload={\n    user_id: id\n}\n\nreturn msg;\n\n//msg.payload = `DELETE FROM users\n//WHERE user_id = ${msg.payload.user_id}\n//RETURNING *;`\n//return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":500,"wires":[["4292afd758f13dce","37d3c1ca7726d122"]]},{"id":"4292afd758f13dce","type":"function","z":"82c72b84094f383a","name":"function  delete 1 id","func":"msg.payload = `DELETE FROM SQLusers\nWHERE user_id = ${msg.payload.user_id}\nRETURNING *;`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":500,"wires":[["c1a1bcc14f5c9ed5","3c87dfae52e1d178"]]},{"id":"c1a1bcc14f5c9ed5","type":"postgres","z":"82c72b84094f383a","postgresdb":"1f17c4cb95c3dc20","name":"EXampleDataBase","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":750,"y":500,"wires":[["fa66e2c0270c270e"]]},{"id":"fa66e2c0270c270e","type":"debug","z":"82c72b84094f383a","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":500,"wires":[]},{"id":"3c87dfae52e1d178","type":"debug","z":"82c72b84094f383a","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":440,"wires":[]},{"id":"37d3c1ca7726d122","type":"debug","z":"82c72b84094f383a","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":540,"wires":[]},{"id":"6a4d4b4432f8dfb6","type":"function","z":"82c72b84094f383a","name":"function  ","func":"\nmsg.payload = `DROP TABLE IF EXISTS SQLusers` \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":600,"wires":[["8bda1a5b4aeda1f4"]]},{"id":"8bda1a5b4aeda1f4","type":"postgres","z":"82c72b84094f383a","postgresdb":"1f17c4cb95c3dc20","name":"EXampleDataBase","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":530,"y":600,"wires":[["27a88695362e63a1"]]},{"id":"27a88695362e63a1","type":"debug","z":"82c72b84094f383a","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":600,"wires":[]},{"id":"01b19c4e5720c7ee","type":"function","z":"82c72b84094f383a","name":"Select","func":"msg.payload = `SELECT * FROM SQLusers  ORDER BY user_id DESC LIMIT 20;`\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":660,"wires":[["2bc5919c9b56f68e","ef1b53821c15a5f8"]]},{"id":"c188bd4001cbf8aa","type":"debug","z":"82c72b84094f383a","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":660,"wires":[]},{"id":"532335a5cfaa3f96","type":"inject","z":"82c72b84094f383a","name":"INSERT 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":140,"wires":[["77ccb41e682022ef","44e2eef69fb5343a","5f68cc23eed341e6"]]},{"id":"77ccb41e682022ef","type":"random-string","z":"82c72b84094f383a","size":"6","characters":"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVWXYZ","property":"payload","x":320,"y":140,"wires":[["d64ba6f5760baddb"]]},{"id":"44e2eef69fb5343a","type":"random-string","z":"82c72b84094f383a","size":"2","characters":"莿桐佳冬牡丹蘆竹大樹路竹竹塘花壇柳營麻豆竹山楊梅卓蘭","property":"payload","x":320,"y":180,"wires":[["1ee2a2f689163ccc"]]},{"id":"5f68cc23eed341e6","type":"random","z":"82c72b84094f383a","name":"","low":"10","high":"75","inte":"true","property":"payload","x":300,"y":100,"wires":[["f9e89d24b84dd7cb"]]},{"id":"ceb62876fd1a340d","type":"debug","z":"82c72b84094f383a","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":830,"y":140,"wires":[]},{"id":"f9e89d24b84dd7cb","type":"function","z":"82c72b84094f383a","name":"function age","func":"var age=msg.payload;\nflow.set('age',age);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":100,"wires":[[]]},{"id":"e1bb6e59cb0ca4a4","type":"function","z":"82c72b84094f383a","name":"function","func":"var name1=flow.get('name');\nvar age1=flow.get('age');\nvar counrty1=flow.get('counrty');\n\n\nmsg.payload={\n    name: name1,\n    age: age1,\n    counrty: counrty1\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":140,"wires":[["ceb62876fd1a340d","f8ecac28d7c68e9e"]]},{"id":"d64ba6f5760baddb","type":"function","z":"82c72b84094f383a","name":"function name","func":"var name=msg.payload;\nflow.set('name',name);\nreturn msg;\n\n\n//msg.payload = `INSERT INTO users(name, age, country)\n//VALUES (\n// '${msg.payload.name}',\n// '${msg.payload.age}', \n// '${msg.payload.counrty}')\n// returning *\n// `\n//return msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":140,"wires":[["e1bb6e59cb0ca4a4"]]},{"id":"1ee2a2f689163ccc","type":"function","z":"82c72b84094f383a","name":"function counrty","func":"var counrty=msg.payload;\nflow.set('counrty',counrty);\nreturn msg;\n\n\n//msg.payload = `INSERT INTO users(name, age, country)\n//VALUES (\n// '${msg.payload.name}',\n// '${msg.payload.age}', \n// '${msg.payload.counrty}')\n// returning *\n// `\n//return msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":180,"wires":[[]]},{"id":"f8e5f7b72e9f02e1","type":"ui_button","z":"82c72b84094f383a","name":"","group":"88c17cd9a0f2b946","order":1,"width":0,"height":0,"passthru":false,"label":"建立資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":110,"y":40,"wires":[["6e67bb4ca0f1c667"]]},{"id":"ed37f761f8bcc278","type":"ui_button","z":"82c72b84094f383a","name":"","group":"88c17cd9a0f2b946","order":4,"width":0,"height":0,"passthru":false,"label":"刪除一筆資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":140,"y":420,"wires":[["cb1d8b0bf333e50a"]]},{"id":"310a3736863db1d4","type":"ui_button","z":"82c72b84094f383a","name":"","group":"88c17cd9a0f2b946","order":2,"width":0,"height":0,"passthru":false,"label":"新增一筆資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":180,"wires":[["5f68cc23eed341e6","77ccb41e682022ef","44e2eef69fb5343a"]]},{"id":"dfc122efcbb1f4d7","type":"ui_text_input","z":"82c72b84094f383a","name":"","label":"刪除的id","tooltip":"","group":"88c17cd9a0f2b946","order":3,"width":0,"height":0,"passthru":true,"mode":"number","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":120,"y":460,"wires":[["6adbd5babdf4709a"]]},{"id":"6adbd5babdf4709a","type":"function","z":"82c72b84094f383a","name":"function ","func":"var id=msg.payload;\nflow.set('id',id);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":260,"y":460,"wires":[[]]},{"id":"effe47628a9be9a9","type":"ui_button","z":"82c72b84094f383a","name":"","group":"88c17cd9a0f2b946","order":5,"width":0,"height":0,"passthru":false,"label":"刪除資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":130,"y":560,"wires":[["6a4d4b4432f8dfb6"]]},{"id":"293ecfab93a2c433","type":"ui_button","z":"82c72b84094f383a","name":"","group":"88c17cd9a0f2b946","order":6,"width":0,"height":0,"passthru":false,"label":"檢視資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":700,"wires":[["01b19c4e5720c7ee"]]},{"id":"189946ae6106a006","type":"link out","z":"82c72b84094f383a","name":"link out 53","mode":"link","links":["a2b21016e78c639e"],"x":855,"y":320,"wires":[]},{"id":"a2b21016e78c639e","type":"link in","z":"82c72b84094f383a","name":"link in 47","links":["189946ae6106a006"],"x":295,"y":720,"wires":[["01b19c4e5720c7ee"]]},{"id":"cb1d8b0bf333e50a","type":"function","z":"82c72b84094f383a","name":"function ","func":"var id1=flow.get('id');\n\nmsg.payload={\n    user_id: id1\n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":420,"wires":[["4292afd758f13dce"]]},{"id":"ef1b53821c15a5f8","type":"debug","z":"82c72b84094f383a","name":"debug 281","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":760,"wires":[]},{"id":"06acda8cfb11609f","type":"debug","z":"82c72b84094f383a","name":"debug 282","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":760,"wires":[]},{"id":"1f17c4cb95c3dc20","type":"postgresdb","cfgname":"EXampleDataBase","hostname":"localhost","port":"5432","db":"EXampleDataBase","ssl":false},{"id":"a7f7734f2e8432de","type":"ui_group","name":"TestDataBase","tab":"564bbb77340e1ba1","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"88c17cd9a0f2b946","type":"ui_group","name":"命令選單","tab":"564bbb77340e1ba1","order":2,"disp":true,"width":"6","collapse":false,"className":""},{"id":"564bbb77340e1ba1","type":"ui_tab","name":"PostgreSQL","icon":"dashboard","order":106,"disabled":false,"hidden":false}]

2024年3月26日 星期二

DHT11 (Node-Red) +PostgreSQL 模擬

 DHT11 (Node-Red) +PostgreSQL 模擬







[{"id":"acddd911a6412f0a","type":"inject","z":"08dc41d47d4d9e09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"15","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":130,"y":140,"wires":[["60f82608b91e1010","a7941c012545db2a"]]},{"id":"60f82608b91e1010","type":"postgrestor","z":"08dc41d47d4d9e09","name":"DHT11","query":"SELECT * FROM DHT11sensor order by time desc limit 1;","postgresDB":"b98af31e5c23d7ac","output":true,"outputs":1,"throwErrors":false,"x":290,"y":140,"wires":[["2536c7ad0157dbf2","cd48a2caa41c4e6d","7c706fad4771614c"]]},{"id":"2536c7ad0157dbf2","type":"ui_gauge","z":"08dc41d47d4d9e09","name":"","group":"49ca43fc9b95bcc1","order":2,"width":"6","height":"4","gtype":"gage","title":"Temperature","label":"C","format":"{{payload.rows[0].temp}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":510,"y":140,"wires":[]},{"id":"cd48a2caa41c4e6d","type":"ui_gauge","z":"08dc41d47d4d9e09","name":"","group":"49ca43fc9b95bcc1","order":3,"width":"6","height":"4","gtype":"gage","title":"Humidity","label":"%","format":"{{payload.rows[0].humidity}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":500,"y":180,"wires":[]},{"id":"cd4adcf359d66588","type":"ui_text","z":"08dc41d47d4d9e09","group":"49ca43fc9b95bcc1","order":1,"width":0,"height":0,"name":"","label":"Update Time:   ","format":"{{msg.payload}}","layout":"row-left","className":"","x":730,"y":100,"wires":[]},{"id":"a7941c012545db2a","type":"postgrestor","z":"08dc41d47d4d9e09","name":"DHT11","query":"select TO_CHAR(time, 'YYYY-MM-DD HH:mm:ss') as time,temp,humidity from (SELECT * FROM DHT11sensor order by time desc limit 30) as data order by time;","postgresDB":"b98af31e5c23d7ac","output":true,"outputs":1,"throwErrors":false,"x":290,"y":220,"wires":[["de934747674f4abc","b6869634764c8604","15f7b694306c2f80"]]},{"id":"bc052292a6aa1f41","type":"ui_chart","z":"08dc41d47d4d9e09","name":"","group":"6879ef9ca30c1e34","order":0,"width":"13","height":"4","label":"Temperature","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":690,"y":220,"wires":[[]]},{"id":"de934747674f4abc","type":"function","z":"08dc41d47d4d9e09","name":"Format chart","func":"var data = [];\nvar label = [];\nvar i;\ndata.push([]);\nfor (i = 0; i < msg.payload.rows.length; i++) \n{\n  data[0].push(msg.payload.rows[i]['temp']);\n}\n\nfor (i = 0; i < msg.payload.rows.length; i++) \n{\n  label.push(msg.payload.rows[i]['time']);\n}\n\nvar m={\n    \"series\":[\"Temperature\"],\n    \"data\":data,\n    \"labels\":label\n};\n\nreturn {payload:[m]};\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":220,"wires":[["bc052292a6aa1f41"]]},{"id":"864f41576f8d37a8","type":"ui_chart","z":"08dc41d47d4d9e09","name":"","group":"6879ef9ca30c1e34","order":0,"width":"13","height":"4","label":"Humidity","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":680,"y":260,"wires":[[]]},{"id":"b6869634764c8604","type":"function","z":"08dc41d47d4d9e09","name":"Format chart","func":"var data = [];\nvar label = [];\nvar i;\ndata.push([]);\nfor (i = 0; i < msg.payload.rows.length; i++) \n{\n  data[0].push(msg.payload.rows[i]['humidity']);\n}\n\nfor (i = 0; i < msg.payload.rows.length; i++) \n{\n  label.push(msg.payload.rows[i]['time']);\n}\n\nvar m={\n    \"series\":[\"Humidity\"],\n    \"data\":data,\n    \"labels\":label\n};\n\nreturn {payload:[m]};\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":260,"wires":[["864f41576f8d37a8"]]},{"id":"15f7b694306c2f80","type":"function","z":"08dc41d47d4d9e09","name":"create array","func":"\nvar i;\nvar list_data = [];\nfor (i = 0; i < msg.payload.rows.length; i++) \n{\n  list_data.push({\"No\":i+1,\"Time\":msg.payload.rows[i]['time'],\"Temperature\":msg.payload.rows[i]['temp'],\n  \"Humidity\":msg.payload.rows[i]['humidity']});\n}\n\nmsg.payload = list_data;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":300,"wires":[["997a83e59f6a3cdc"]]},{"id":"997a83e59f6a3cdc","type":"ui_table","z":"08dc41d47d4d9e09","group":"756d53853a29259a","name":"","order":0,"width":"8","height":"14","columns":[],"outputs":1,"cts":true,"x":670,"y":300,"wires":[["7fd94d3ea87889b9"]]},{"id":"7fd94d3ea87889b9","type":"template","z":"08dc41d47d4d9e09","name":"","field":"payload","fieldType":"msg","format":"html","syntax":"mustache","template":"Time: {{payload.Time}}<br>\nTemperature: {{payload.Temperature}}<br>\nHumidity: {{payload.Humidity}}<br>","output":"str","x":790,"y":300,"wires":[["5d991cfa9fbd5624"]]},{"id":"5d991cfa9fbd5624","type":"ui_toast","z":"08dc41d47d4d9e09","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":true,"className":"","topic":"Data","name":"","x":950,"y":300,"wires":[]},{"id":"b7a62274d2e3e00a","type":"inject","z":"08dc41d47d4d9e09","name":"CREATE","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":400,"wires":[["7b87c1255de70067"]]},{"id":"47c2279e27890264","type":"inject","z":"08dc41d47d4d9e09","name":"INSERT 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":480,"wires":[["77ce9a8be017a108","b1e6cd67c3efbc9a","6bad2a6dc37cea5d"]]},{"id":"77ce9a8be017a108","type":"random","z":"08dc41d47d4d9e09","name":"temp","low":"10","high":"45","inte":"true","property":"payload","x":310,"y":440,"wires":[["a2b84168d315fcb0"]]},{"id":"6bad2a6dc37cea5d","type":"function","z":"08dc41d47d4d9e09","name":"function name","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;\nvar date_time = yyyy+'/'+MM+'/'+dd+ ' '+h+':'+m+':'+s;\n\nmsg.payload=date_time;\nflow.set('time',date_time);\nreturn msg;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":520,"wires":[["90ba57a6962cd376"]]},{"id":"a2b84168d315fcb0","type":"function","z":"08dc41d47d4d9e09","name":"function temp","func":"var temp=msg.payload;\nflow.set('temp',temp);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":440,"wires":[[]]},{"id":"d28a9b235c2408b3","type":"postgres","z":"08dc41d47d4d9e09","postgresdb":"d02a35f8c3a63a7c","name":"DHT11","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":490,"y":400,"wires":[["eee469a9a3490ab3"]]},{"id":"7b87c1255de70067","type":"function","z":"08dc41d47d4d9e09","name":"function  ","func":"msg.payload = `CREATE TABLE DHT11sensor(\n    user_id serial PRIMARY KEY,\n    time timestamp,\n    temp float4,\n    humidity float4\n)`\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":400,"wires":[["d28a9b235c2408b3"]]},{"id":"90ba57a6962cd376","type":"function","z":"08dc41d47d4d9e09","name":"function","func":"var time1=flow.get('time');\nvar temp1=flow.get('temp');\nvar humidity1=flow.get('humidity');\n\n\nmsg.payload={\n    time: time1,\n    temp: temp1,\n    humidity: humidity1\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":520,"wires":[["4f835c264a3542bb","c6e36a0b21561204"]]},{"id":"eee469a9a3490ab3","type":"debug","z":"08dc41d47d4d9e09","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":400,"wires":[]},{"id":"4f835c264a3542bb","type":"debug","z":"08dc41d47d4d9e09","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":520,"wires":[]},{"id":"c6e36a0b21561204","type":"function","z":"08dc41d47d4d9e09","name":"function   Add db ","func":"msg.payload = `INSERT INTO DHT11sensor( time, temp, humidity)\nVALUES (\n '${msg.payload.time}',\n '${msg.payload.temp}', \n '${msg.payload.humidity}')\n returning *\n`\nreturn msg;\n\n\n//msg.payload = `CREATE TABLE DHT11sensor(\n//    user_id serial PRIMARY KEY,\n//    time timestamp,\n//    temp float4,\n//    humidity float4\n//)`\n\n//return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":620,"wires":[["e621d8a99137d96f"]]},{"id":"e621d8a99137d96f","type":"postgres","z":"08dc41d47d4d9e09","postgresdb":"d02a35f8c3a63a7c","name":"DHT11","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":730,"y":620,"wires":[["89398818c2863b22"]]},{"id":"89398818c2863b22","type":"debug","z":"08dc41d47d4d9e09","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":620,"wires":[]},{"id":"b1e6cd67c3efbc9a","type":"random","z":"08dc41d47d4d9e09","name":"humidity","low":"25","high":"100","inte":"true","property":"payload","x":320,"y":480,"wires":[["b2012bfbe7bb4b05"]]},{"id":"b2012bfbe7bb4b05","type":"function","z":"08dc41d47d4d9e09","name":"function humidity","func":"var humidity=msg.payload;\nflow.set('humidity',humidity);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":480,"wires":[[]]},{"id":"7c706fad4771614c","type":"function","z":"08dc41d47d4d9e09","name":"Format chart","func":"var time2 =msg.payload.rows[0].time;\n\nmsg.payload=time2;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":100,"wires":[["cd4adcf359d66588"]]},{"id":"b98af31e5c23d7ac","type":"postgresDB","name":"DHT11","throwErrors":true,"throwErrorsFieldType":"bool","host":"127.0.0.1","hostFieldType":"str","port":"5432","portFieldType":"num","database":"DHT11","databaseFieldType":"str","ssl":"false","sslFieldType":"bool","max":"10","maxFieldType":"num","min":"1","minFieldType":"num","idle":"1000","idleFieldType":"num","connectionTimeout":"10000","connectionTimeoutFieldType":"num","user":"postgres","userFieldType":"str","password":"Alex9981","passwordFieldType":"str"},{"id":"49ca43fc9b95bcc1","type":"ui_group","name":"Current Temperature & Humidity","tab":"50b4e86120098aeb","order":1,"disp":true,"width":"13","collapse":false,"className":""},{"id":"6879ef9ca30c1e34","type":"ui_group","name":"Chart","tab":"50b4e86120098aeb","order":2,"disp":true,"width":"13","collapse":false,"className":""},{"id":"756d53853a29259a","type":"ui_group","name":"Raw Data Table","tab":"50b4e86120098aeb","order":3,"disp":true,"width":"8","collapse":false,"className":""},{"id":"d02a35f8c3a63a7c","type":"postgresdb","cfgname":"DHT11","hostname":"localhost","port":"5432","db":"DHT11","ssl":false},{"id":"50b4e86120098aeb","type":"ui_tab","name":"DHT-11","icon":"dashboard","order":7,"disabled":false,"hidden":false}]


更新後


[{"id":"acddd911a6412f0a","type":"inject","z":"08dc41d47d4d9e09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"15","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":130,"y":140,"wires":[["60f82608b91e1010","a7941c012545db2a"]]},{"id":"60f82608b91e1010","type":"postgrestor","z":"08dc41d47d4d9e09","name":"DHT11","query":"SELECT * FROM DHT11sensor order by time desc limit 1;","postgresDB":"b98af31e5c23d7ac","output":true,"outputs":1,"throwErrors":false,"x":290,"y":140,"wires":[["2536c7ad0157dbf2","cd48a2caa41c4e6d","7c706fad4771614c","16216b92fe56954d"]]},{"id":"2536c7ad0157dbf2","type":"ui_gauge","z":"08dc41d47d4d9e09","name":"","group":"49ca43fc9b95bcc1","order":2,"width":"6","height":"4","gtype":"gage","title":"Temperature","label":"C","format":"{{payload.rows[0].temp}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":510,"y":140,"wires":[]},{"id":"cd48a2caa41c4e6d","type":"ui_gauge","z":"08dc41d47d4d9e09","name":"","group":"49ca43fc9b95bcc1","order":3,"width":"6","height":"4","gtype":"gage","title":"Humidity","label":"%","format":"{{payload.rows[0].humidity}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":500,"y":180,"wires":[]},{"id":"cd4adcf359d66588","type":"ui_text","z":"08dc41d47d4d9e09","group":"49ca43fc9b95bcc1","order":1,"width":0,"height":0,"name":"","label":"Update Time:   ","format":"{{msg.payload}}","layout":"row-left","className":"","x":730,"y":100,"wires":[]},{"id":"a7941c012545db2a","type":"postgrestor","z":"08dc41d47d4d9e09","name":"DHT11","query":"select TO_CHAR(time, 'YYYY-MM-DD HH:mm:ss') as time,temp,humidity from (SELECT * FROM DHT11sensor order by time desc limit 30) as data order by time;","postgresDB":"b98af31e5c23d7ac","output":true,"outputs":1,"throwErrors":false,"x":290,"y":220,"wires":[["de934747674f4abc","b6869634764c8604","15f7b694306c2f80"]]},{"id":"bc052292a6aa1f41","type":"ui_chart","z":"08dc41d47d4d9e09","name":"","group":"6879ef9ca30c1e34","order":0,"width":"13","height":"4","label":"Temperature","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":690,"y":220,"wires":[[]]},{"id":"de934747674f4abc","type":"function","z":"08dc41d47d4d9e09","name":"Format chart","func":"var data = [];\nvar label = [];\nvar i;\ndata.push([]);\nfor (i = 0; i < msg.payload.rows.length; i++) \n{\n  data[0].push(msg.payload.rows[i]['temp']);\n}\n\nfor (i = 0; i < msg.payload.rows.length; i++) \n{\n  label.push(msg.payload.rows[i]['time']);\n}\n\nvar m={\n    \"series\":[\"Temperature\"],\n    \"data\":data,\n    \"labels\":label\n};\n\nreturn {payload:[m]};\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":220,"wires":[["bc052292a6aa1f41"]]},{"id":"864f41576f8d37a8","type":"ui_chart","z":"08dc41d47d4d9e09","name":"","group":"6879ef9ca30c1e34","order":0,"width":"13","height":"4","label":"Humidity","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":680,"y":260,"wires":[[]]},{"id":"b6869634764c8604","type":"function","z":"08dc41d47d4d9e09","name":"Format chart","func":"var data = [];\nvar label = [];\nvar i;\ndata.push([]);\nfor (i = 0; i < msg.payload.rows.length; i++) \n{\n  data[0].push(msg.payload.rows[i]['humidity']);\n}\n\nfor (i = 0; i < msg.payload.rows.length; i++) \n{\n  label.push(msg.payload.rows[i]['time']);\n}\n\nvar m={\n    \"series\":[\"Humidity\"],\n    \"data\":data,\n    \"labels\":label\n};\n\nreturn {payload:[m]};\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":260,"wires":[["864f41576f8d37a8"]]},{"id":"15f7b694306c2f80","type":"function","z":"08dc41d47d4d9e09","name":"create array","func":"\nvar i;\nvar list_data = [];\nfor (i = 0; i < msg.payload.rows.length; i++) \n{\n  list_data.push({\"No\":i+1,\"Time\":msg.payload.rows[i]['time'],\"Temperature\":msg.payload.rows[i]['temp'],\n  \"Humidity\":msg.payload.rows[i]['humidity']});\n}\n\nmsg.payload = list_data;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":300,"wires":[["997a83e59f6a3cdc"]]},{"id":"997a83e59f6a3cdc","type":"ui_table","z":"08dc41d47d4d9e09","group":"756d53853a29259a","name":"","order":0,"width":"8","height":"14","columns":[],"outputs":1,"cts":true,"x":670,"y":300,"wires":[[]]},{"id":"7fd94d3ea87889b9","type":"template","z":"08dc41d47d4d9e09","name":"","field":"payload","fieldType":"msg","format":"html","syntax":"mustache","template":"\nTime: {{payload.time}} <br>\nTemperature: {{payload.temp}} <br>\nHumidity: {{payload.humidity}} <br>\n","output":"str","x":670,"y":40,"wires":[["5d991cfa9fbd5624"]]},{"id":"5d991cfa9fbd5624","type":"ui_toast","z":"08dc41d47d4d9e09","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":true,"className":"","topic":"Data","name":"","x":830,"y":40,"wires":[]},{"id":"b7a62274d2e3e00a","type":"inject","z":"08dc41d47d4d9e09","name":"CREATE","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":400,"wires":[["7b87c1255de70067"]]},{"id":"47c2279e27890264","type":"inject","z":"08dc41d47d4d9e09","name":"INSERT 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":480,"wires":[["77ce9a8be017a108","b1e6cd67c3efbc9a","6bad2a6dc37cea5d"]]},{"id":"77ce9a8be017a108","type":"random","z":"08dc41d47d4d9e09","name":"temp","low":"10","high":"45","inte":"true","property":"payload","x":310,"y":440,"wires":[["a2b84168d315fcb0"]]},{"id":"6bad2a6dc37cea5d","type":"function","z":"08dc41d47d4d9e09","name":"function name","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;\nvar date_time = yyyy+'/'+MM+'/'+dd+ ' '+h+':'+m+':'+s;\n\nmsg.payload=date_time;\nflow.set('time',date_time);\nreturn msg;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":520,"wires":[["90ba57a6962cd376"]]},{"id":"a2b84168d315fcb0","type":"function","z":"08dc41d47d4d9e09","name":"function temp","func":"var temp=msg.payload;\nflow.set('temp',temp);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":440,"wires":[[]]},{"id":"d28a9b235c2408b3","type":"postgres","z":"08dc41d47d4d9e09","postgresdb":"d02a35f8c3a63a7c","name":"DHT11","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":490,"y":400,"wires":[["eee469a9a3490ab3"]]},{"id":"7b87c1255de70067","type":"function","z":"08dc41d47d4d9e09","name":"function  ","func":"msg.payload = `CREATE TABLE DHT11sensor(\n    user_id serial PRIMARY KEY,\n    time timestamp,\n    temp float4,\n    humidity float4\n)`\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":400,"wires":[["d28a9b235c2408b3"]]},{"id":"90ba57a6962cd376","type":"function","z":"08dc41d47d4d9e09","name":"function","func":"var time1=flow.get('time');\nvar temp1=flow.get('temp');\nvar humidity1=flow.get('humidity');\n\n\nmsg.payload={\n    time: time1,\n    temp: temp1,\n    humidity: humidity1\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":520,"wires":[["4f835c264a3542bb","c6e36a0b21561204"]]},{"id":"eee469a9a3490ab3","type":"debug","z":"08dc41d47d4d9e09","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":400,"wires":[]},{"id":"4f835c264a3542bb","type":"debug","z":"08dc41d47d4d9e09","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":520,"wires":[]},{"id":"c6e36a0b21561204","type":"function","z":"08dc41d47d4d9e09","name":"function   Add db ","func":"msg.payload = `INSERT INTO DHT11sensor( time, temp, humidity)\nVALUES (\n '${msg.payload.time}',\n '${msg.payload.temp}', \n '${msg.payload.humidity}')\n returning *\n`\nreturn msg;\n\n\n//msg.payload = `CREATE TABLE DHT11sensor(\n//    user_id serial PRIMARY KEY,\n//    time timestamp,\n//    temp float4,\n//    humidity float4\n//)`\n\n//return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":620,"wires":[["e621d8a99137d96f"]]},{"id":"e621d8a99137d96f","type":"postgres","z":"08dc41d47d4d9e09","postgresdb":"d02a35f8c3a63a7c","name":"DHT11","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":730,"y":620,"wires":[["89398818c2863b22"]]},{"id":"89398818c2863b22","type":"debug","z":"08dc41d47d4d9e09","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":620,"wires":[]},{"id":"b1e6cd67c3efbc9a","type":"random","z":"08dc41d47d4d9e09","name":"humidity","low":"25","high":"100","inte":"true","property":"payload","x":320,"y":480,"wires":[["b2012bfbe7bb4b05"]]},{"id":"b2012bfbe7bb4b05","type":"function","z":"08dc41d47d4d9e09","name":"function humidity","func":"var humidity=msg.payload;\nflow.set('humidity',humidity);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":480,"wires":[[]]},{"id":"7c706fad4771614c","type":"function","z":"08dc41d47d4d9e09","name":"Format chart","func":"var time2 =msg.payload.rows[0].time;\n\nmsg.payload=time2;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":100,"wires":[["cd4adcf359d66588"]]},{"id":"16216b92fe56954d","type":"function","z":"08dc41d47d4d9e09","name":"function 96","func":"\nvar time2 =msg.payload.rows[0].time;\nvar temp2 =msg.payload.rows[0].temp;\nvar humidity2 =msg.payload.rows[0].humidity;\n\nmsg.payload.time=time2;\nmsg.payload.temp=temp2;\nmsg.payload.humidity=humidity2;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":40,"wires":[["7fd94d3ea87889b9"]]},{"id":"b98af31e5c23d7ac","type":"postgresDB","name":"DHT11","throwErrors":true,"throwErrorsFieldType":"bool","host":"127.0.0.1","hostFieldType":"str","port":"5432","portFieldType":"num","database":"DHT11","databaseFieldType":"str","ssl":"false","sslFieldType":"bool","max":"10","maxFieldType":"num","min":"1","minFieldType":"num","idle":"1000","idleFieldType":"num","connectionTimeout":"10000","connectionTimeoutFieldType":"num","user":"postgres","userFieldType":"str","password":"Alex9981","passwordFieldType":"str"},{"id":"49ca43fc9b95bcc1","type":"ui_group","name":"Current Temperature & Humidity","tab":"50b4e86120098aeb","order":1,"disp":true,"width":"13","collapse":false,"className":""},{"id":"6879ef9ca30c1e34","type":"ui_group","name":"Chart","tab":"50b4e86120098aeb","order":2,"disp":true,"width":"13","collapse":false,"className":""},{"id":"756d53853a29259a","type":"ui_group","name":"Raw Data Table","tab":"50b4e86120098aeb","order":3,"disp":true,"width":"8","collapse":false,"className":""},{"id":"d02a35f8c3a63a7c","type":"postgresdb","cfgname":"DHT11","hostname":"localhost","port":"5432","db":"DHT11","ssl":false},{"id":"50b4e86120098aeb","type":"ui_tab","name":"DHT-11","icon":"dashboard","order":7,"disabled":false,"hidden":false}]

PostgerSQL 與 Node-Red

 PostgerSQL DataBase  與 Node-Red































[{"id":"368fd7c606e21cb8","type":"function","z":"332ada08f7c3884c","name":"function  ","func":"msg.payload = `CREATE TABLE users(\n    user_id serial PRIMARY KEY,\n    name  TEXT,\n    age INTEGER,\n    country TEXT\n)`\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":80,"wires":[["022940eec34e041c"]]},{"id":"a6fd40995423c258","type":"debug","z":"332ada08f7c3884c","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":80,"wires":[]},{"id":"dbf51f2fcc3b143f","type":"function","z":"332ada08f7c3884c","name":"function   Add db ","func":"msg.payload = `INSERT INTO users(name, age, country)\nVALUES (\n '${msg.payload.name}',\n '${msg.payload.age}', \n '${msg.payload.counrty}')\n returning *\n`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":300,"wires":[["7599576986151811","dd33360f7276583f"]]},{"id":"5d3303b659ae7f6a","type":"debug","z":"332ada08f7c3884c","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":300,"wires":[]},{"id":"5aa6c63c158de02d","type":"inject","z":"332ada08f7c3884c","name":"SELECT","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":360,"wires":[["4cbfc7dcace15357"]]},{"id":"60a1d235017ebe03","type":"inject","z":"332ada08f7c3884c","name":"DELETE","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":520,"wires":[["94046098bbf1addc"]]},{"id":"c844e70b99dcd33a","type":"inject","z":"332ada08f7c3884c","name":"DROP TABLE","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"DROP TABLE LEDSTATUS","payload":"","payloadType":"date","x":150,"y":620,"wires":[["0a43d4e75df79b55"]]},{"id":"3a4d50f5cdcd3f0c","type":"inject","z":"332ada08f7c3884c","name":"View Records","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":680,"wires":[["509b81485d309434"]]},{"id":"82d575b127105d8d","type":"ui_template","z":"332ada08f7c3884c","group":"eac63b546871af8c","name":"UI Table","order":1,"width":6,"height":6,"format":"<table style=\"width:100%\">\n  <tr>\n    <th>user_id</th> \n    <th>name</th> \n    <th>age</th>     \n    <th>country</th>\n  </tr>\n  <tr ng-repeat=\"x in msg.payload | limitTo:20\">\n    <td>{{msg.payload[$index].user_id}}</td>\n    <td>{{msg.payload[$index].name}}</td> \n    <td>{{msg.payload[$index].age}}</td>\n    <td>{{msg.payload[$index].country}}</td>  \n  </tr>\n</table>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":640,"y":680,"wires":[["4d536e61de01044f"]]},{"id":"99e2ec5923c2c192","type":"inject","z":"332ada08f7c3884c","name":"CREATE","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":100,"wires":[["368fd7c606e21cb8"]]},{"id":"73088c78162be0b5","type":"inject","z":"332ada08f7c3884c","name":"INSERT","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":300,"wires":[["994de9c68c3b6035"]]},{"id":"994de9c68c3b6035","type":"function","z":"332ada08f7c3884c","name":"function ","func":"\nmsg.payload={\n    name: 'Alex',\n    age: 50,\n    counrty: '大里'\n}\n\nreturn msg;\n\n//msg.payload = `INSERT INTO users(name, age, country)\n//VALUES (\n// '${msg.payload.name}',\n// '${msg.payload.age}', \n// '${msg.payload.counrty}')\n// returning *\n// `\n//return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":300,"wires":[["dbf51f2fcc3b143f","a09f5660dab67365"]]},{"id":"7599576986151811","type":"debug","z":"332ada08f7c3884c","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":260,"wires":[]},{"id":"a09f5660dab67365","type":"debug","z":"332ada08f7c3884c","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":430,"y":240,"wires":[]},{"id":"4cbfc7dcace15357","type":"function","z":"332ada08f7c3884c","name":"Select","func":"msg.payload = `SELECT * FROM users `\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":270,"y":360,"wires":[["da2b4730565f24be","54a55197ee853aff"]]},{"id":"da2b4730565f24be","type":"debug","z":"332ada08f7c3884c","name":"debug  ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":450,"y":400,"wires":[]},{"id":"4c5713185701dd7a","type":"debug","z":"332ada08f7c3884c","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":360,"wires":[]},{"id":"94046098bbf1addc","type":"function","z":"332ada08f7c3884c","name":"function ","func":"var id=msg.payload;\n\nmsg.payload={\n    user_id: id\n}\n\nreturn msg;\n\n//msg.payload = `DELETE FROM users\n//WHERE user_id = ${msg.payload.user_id}\n//RETURNING *;`\n//return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":520,"wires":[["efa890e372a46018","50114b26c3c776b4"]]},{"id":"efa890e372a46018","type":"function","z":"332ada08f7c3884c","name":"function  delete 1 id","func":"msg.payload = `DELETE FROM users\nWHERE user_id = ${msg.payload.user_id}\nRETURNING *;`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":520,"wires":[["d0d028556668a8c9","401d22293b1f6ebe"]]},{"id":"b178cc2ae4246ed8","type":"debug","z":"332ada08f7c3884c","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":520,"wires":[]},{"id":"d0d028556668a8c9","type":"debug","z":"332ada08f7c3884c","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":460,"wires":[]},{"id":"50114b26c3c776b4","type":"debug","z":"332ada08f7c3884c","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":560,"wires":[]},{"id":"0a43d4e75df79b55","type":"function","z":"332ada08f7c3884c","name":"function  ","func":"\nmsg.payload = `DROP TABLE IF EXISTS users` \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":620,"wires":[["bd22e5d304c51305"]]},{"id":"f8d77aa8821a36f2","type":"debug","z":"332ada08f7c3884c","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":620,"wires":[]},{"id":"509b81485d309434","type":"function","z":"332ada08f7c3884c","name":"Select","func":"msg.payload = `SELECT * FROM users `\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":680,"wires":[["4471e445acf1cb53"]]},{"id":"4d536e61de01044f","type":"debug","z":"332ada08f7c3884c","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":680,"wires":[]},{"id":"0955139fc98c2b3a","type":"inject","z":"332ada08f7c3884c","name":"INSERT 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":160,"wires":[["a1389a3387c03c49","14c6411e71e4a2d8","87e58dab50e5374c"]]},{"id":"a1389a3387c03c49","type":"random-string","z":"332ada08f7c3884c","size":"6","characters":"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVWXYZ","property":"payload","x":320,"y":160,"wires":[["883de01c6e83dbce"]]},{"id":"14c6411e71e4a2d8","type":"random-string","z":"332ada08f7c3884c","size":"2","characters":"莿桐佳冬牡丹蘆竹大樹路竹竹塘花壇柳營麻豆竹山楊梅卓蘭","property":"payload","x":320,"y":200,"wires":[["1fc83997d4b318b3"]]},{"id":"87e58dab50e5374c","type":"random","z":"332ada08f7c3884c","name":"","low":"10","high":"75","inte":"true","property":"payload","x":300,"y":120,"wires":[["0a351e32feb580bb"]]},{"id":"217866abe56a5664","type":"debug","z":"332ada08f7c3884c","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":830,"y":160,"wires":[]},{"id":"0a351e32feb580bb","type":"function","z":"332ada08f7c3884c","name":"function age","func":"var age=msg.payload;\nflow.set('age',age);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":120,"wires":[[]]},{"id":"41f8d2287274be88","type":"function","z":"332ada08f7c3884c","name":"function","func":"var name1=flow.get('name');\nvar age1=flow.get('age');\nvar counrty1=flow.get('counrty');\n\n\nmsg.payload={\n    name: name1,\n    age: age1,\n    counrty: counrty1\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":160,"wires":[["217866abe56a5664","dbf51f2fcc3b143f"]]},{"id":"883de01c6e83dbce","type":"function","z":"332ada08f7c3884c","name":"function name","func":"var name=msg.payload;\nflow.set('name',name);\nreturn msg;\n\n\n//msg.payload = `INSERT INTO users(name, age, country)\n//VALUES (\n// '${msg.payload.name}',\n// '${msg.payload.age}', \n// '${msg.payload.counrty}')\n// returning *\n// `\n//return msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":160,"wires":[["41f8d2287274be88"]]},{"id":"1fc83997d4b318b3","type":"function","z":"332ada08f7c3884c","name":"function counrty","func":"var counrty=msg.payload;\nflow.set('counrty',counrty);\nreturn msg;\n\n\n//msg.payload = `INSERT INTO users(name, age, country)\n//VALUES (\n// '${msg.payload.name}',\n// '${msg.payload.age}', \n// '${msg.payload.counrty}')\n// returning *\n// `\n//return msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":200,"wires":[[]]},{"id":"711b8e83b4705634","type":"ui_button","z":"332ada08f7c3884c","name":"","group":"99c5c3145bc0ee30","order":1,"width":0,"height":0,"passthru":false,"label":"建立資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":110,"y":60,"wires":[["368fd7c606e21cb8"]]},{"id":"fcbaaa9ea881c669","type":"ui_button","z":"332ada08f7c3884c","name":"","group":"99c5c3145bc0ee30","order":4,"width":0,"height":0,"passthru":false,"label":"刪除一筆資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":140,"y":440,"wires":[["379b9d0827becc9d"]]},{"id":"76e85b59f83cc448","type":"ui_button","z":"332ada08f7c3884c","name":"","group":"99c5c3145bc0ee30","order":2,"width":0,"height":0,"passthru":false,"label":"新增一筆資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":200,"wires":[["87e58dab50e5374c","a1389a3387c03c49","14c6411e71e4a2d8"]]},{"id":"5dee94da6f9c5176","type":"ui_text_input","z":"332ada08f7c3884c","name":"","label":"刪除的id","tooltip":"","group":"99c5c3145bc0ee30","order":3,"width":0,"height":0,"passthru":true,"mode":"number","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":120,"y":480,"wires":[["88438e9442722009"]]},{"id":"88438e9442722009","type":"function","z":"332ada08f7c3884c","name":"function ","func":"var id=msg.payload;\nflow.set('id',id);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":260,"y":480,"wires":[[]]},{"id":"12e5335234757b7c","type":"ui_button","z":"332ada08f7c3884c","name":"","group":"99c5c3145bc0ee30","order":5,"width":0,"height":0,"passthru":false,"label":"刪除資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":130,"y":580,"wires":[["0a43d4e75df79b55"]]},{"id":"f466b482638634d4","type":"ui_button","z":"332ada08f7c3884c","name":"","group":"99c5c3145bc0ee30","order":6,"width":0,"height":0,"passthru":false,"label":"檢視資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":720,"wires":[["509b81485d309434"]]},{"id":"361c500b6ef7ac2b","type":"link out","z":"332ada08f7c3884c","name":"link out 54","mode":"link","links":["97ecb617f9fa6786"],"x":845,"y":380,"wires":[]},{"id":"97ecb617f9fa6786","type":"link in","z":"332ada08f7c3884c","name":"link in 48","links":["361c500b6ef7ac2b"],"x":295,"y":740,"wires":[["509b81485d309434"]]},{"id":"379b9d0827becc9d","type":"function","z":"332ada08f7c3884c","name":"function ","func":"var id1=flow.get('id');\n\nmsg.payload={\n    user_id: id1\n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":440,"wires":[["efa890e372a46018"]]},{"id":"022940eec34e041c","type":"postgres","z":"332ada08f7c3884c","postgresdb":"b9aae012f9a45a3d","name":"PostgreSQL2","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":560,"y":80,"wires":[["a6fd40995423c258"]]},{"id":"dd33360f7276583f","type":"postgres","z":"332ada08f7c3884c","postgresdb":"b9aae012f9a45a3d","name":"PostgreSQL2","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":720,"y":300,"wires":[["5d3303b659ae7f6a","361c500b6ef7ac2b"]]},{"id":"54a55197ee853aff","type":"postgres","z":"332ada08f7c3884c","postgresdb":"b9aae012f9a45a3d","name":"PostgreSQL2","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":480,"y":360,"wires":[["4c5713185701dd7a"]]},{"id":"401d22293b1f6ebe","type":"postgres","z":"332ada08f7c3884c","postgresdb":"b9aae012f9a45a3d","name":"PostgreSQL2","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":720,"y":520,"wires":[["b178cc2ae4246ed8"]]},{"id":"bd22e5d304c51305","type":"postgres","z":"332ada08f7c3884c","postgresdb":"b9aae012f9a45a3d","name":"PostgreSQL2","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":520,"y":620,"wires":[["f8d77aa8821a36f2"]]},{"id":"4471e445acf1cb53","type":"postgres","z":"332ada08f7c3884c","postgresdb":"b9aae012f9a45a3d","name":"PostgreSQL2","output":true,"perrow":false,"rowspermsg":"1","return_on_error":false,"limit_queries":"0","limit_by":"payload","limit_value":"1","limit_drop_intermediate":false,"limit_drop_if_in_queue":false,"outputs":true,"x":480,"y":680,"wires":[["82d575b127105d8d"]]},{"id":"eac63b546871af8c","type":"ui_group","name":"PostgreSQL2","tab":"564bbb77340e1ba1","order":3,"disp":true,"width":"6","collapse":false,"className":""},{"id":"99c5c3145bc0ee30","type":"ui_group","name":"PostSQL2選單","tab":"564bbb77340e1ba1","order":4,"disp":true,"width":"6","collapse":false,"className":""},{"id":"b9aae012f9a45a3d","type":"postgresdb","cfgname":"PostgreSQL2","hostname":"localhost","port":"5432","db":"PostgreSQL2","ssl":false,"credentials":{}},{"id":"564bbb77340e1ba1","type":"ui_tab","name":"PostgreSQL","icon":"dashboard","order":106,"disabled":false,"hidden":false}]

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}]



WOKWI LED + MQTT Node-Red SQLite

WOKWI LED + MQTT Node-Red SQLite const char *mqtt_broker = "broker.mqtt-dashboard.com" ; const char *topic1 = "alex9ufo/e...