2023年8月11日 星期五

Node-Red + SQLite 新增 更正 刪除一筆 刪除全部 刪除資料庫 建立資料庫

 Node-Red + SQLite 新增 更正 刪除一筆 刪除全部 刪除資料庫  建立資料庫







[{"id":"0e2637f17c434126","type":"ui_button","z":"33daa526a61fd4fe","name":"","group":"0c7dcb8629852c78","order":1,"width":3,"height":1,"passthru":false,"label":"建立資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":90,"y":100,"wires":[["cecb7f3f60ad0b05"]]},{"id":"17c2f2b08a713cac","type":"ui_button","z":"33daa526a61fd4fe","name":"","group":"0c7dcb8629852c78","order":2,"width":4,"height":1,"passthru":false,"label":"新增一筆資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":100,"y":140,"wires":[["f5a21bcfb3f68498"]]},{"id":"623848dbf69e3337","type":"ui_button","z":"33daa526a61fd4fe","name":"","group":"0c7dcb8629852c78","order":5,"width":7,"height":2,"passthru":false,"label":"檢視資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":80,"y":200,"wires":[["c81728395a38ee81"]]},{"id":"aa7d0b89fb1ffe02","type":"ui_button","z":"33daa526a61fd4fe","name":"","group":"0c7dcb8629852c78","order":9,"width":2,"height":1,"passthru":false,"label":"刪除所有資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":100,"y":420,"wires":[["b3a96681d913be03"]]},{"id":"5edaea5096eee070","type":"sqlite","z":"33daa526a61fd4fe","mydb":"dd7f8134e015a1cb","sqlquery":"msg.topic","sql":"","name":"My_sensor","x":570,"y":140,"wires":[["cf2aaaf474751396"]]},{"id":"cecb7f3f60ad0b05","type":"function","z":"33daa526a61fd4fe","name":"CREATE DATABASE","func":"//CREATE TABLE dhtreadings(id INTEGER PRIMARY KEY AUTOINCREMENT,\n//temperature NUMERIC, \n//humidity NUMERIC, \n//currentdate DATE, \n//currenttime TIME,\n//device TEXT)\nmsg.topic = \"CREATE TABLE dhtreadings(id INTEGER PRIMARY KEY AUTOINCREMENT, temperature NUMERIC, humidity NUMERIC, currentdate DATE, currenttime TIME, device TEXT)\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":100,"wires":[["5edaea5096eee070"]]},{"id":"cf2aaaf474751396","type":"debug","z":"33daa526a61fd4fe","name":"debug 166","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":760,"y":140,"wires":[]},{"id":"f5a21bcfb3f68498","type":"function","z":"33daa526a61fd4fe","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();     //秒\n\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}\n\nvar var_date = yyyy+'/'+MM+'/'+dd;\nvar var_time = h+':'+m+':'+s;\nvar max= 40;\nvar min= 20;\nvar var_device = 'DEVICE'+ Math.round(Math.random() * (max - min) + min);\n\n//return msg;\nvar max2=50;\nvar min2=10;\nvar myTemp = Math.round(Math.random() * (max2 - min2) + min2);\nvar max1=100;\nvar min1= 20;\nvar myHumi = Math.round(Math.random() * (max1 - min1) + min1);\n\nmsg.topic = \"INSERT INTO dhtreadings  ( temperature , humidity , currentdate, currenttime ,device  ) VALUES ($myTemp, $myHumi, $var_date ,  $var_time  , $var_device) \" ;\nmsg.payload = [myTemp, myHumi, var_date , var_time  , var_device]\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":140,"wires":[["5edaea5096eee070","c81728395a38ee81"]]},{"id":"7ba37854c55531c4","type":"function","z":"33daa526a61fd4fe","name":"刪除所有資料","func":"//DELETE from dhtreadings\nmsg.topic = \"DELETE from dhtreadings\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":420,"wires":[["663cea2aa3a41817"]]},{"id":"245a5d9a02f6bcb9","type":"sqlite","z":"33daa526a61fd4fe","mydb":"dd7f8134e015a1cb","sqlquery":"msg.topic","sql":"","name":"My_sensor","x":590,"y":340,"wires":[["ad11bd414726153a"]]},{"id":"6d9d6b8aa4990afc","type":"ui_button","z":"33daa526a61fd4fe","name":"","group":"0c7dcb8629852c78","order":11,"width":2,"height":1,"passthru":false,"label":"刪除資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":90,"y":380,"wires":[["4f752e3354523649"]]},{"id":"f2ba2da74f704218","type":"function","z":"33daa526a61fd4fe","name":"刪除資料庫","func":"//DROP TABLE dhtreadings\nmsg.topic = \"DROP TABLE dhtreadings\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":380,"wires":[["245a5d9a02f6bcb9"]]},{"id":"ad11bd414726153a","type":"debug","z":"33daa526a61fd4fe","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":340,"wires":[]},{"id":"c81728395a38ee81","type":"function","z":"33daa526a61fd4fe","name":"檢視資料","func":"//SELECT * FROM dhtreadings ORDER BY  id DESC LIMIT 50;\n\n//msg.topic = \"SELECT * FROM dhtreadings ORDER BY  id DESC LIMIT 50\";\nmsg.topic = \"SELECT * FROM dhtreadings ORDER BY  id DESC \";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":200,"wires":[["04ac2dec556488fa"]]},{"id":"04ac2dec556488fa","type":"sqlite","z":"33daa526a61fd4fe","mydb":"dd7f8134e015a1cb","sqlquery":"msg.topic","sql":"","name":"My_sensor","x":570,"y":200,"wires":[["54cdd2a0d639323a","26967a922bc08b50","626ba55e2438764f"]]},{"id":"8b31d0247712f507","type":"function","z":"33daa526a61fd4fe","name":"SELECT id","func":"var del_idtemp=msg.payload;\nflow.set(\"idtemp\", del_idtemp);\n\nmsg.topic = \"SELECT * FROM dhtreadings \";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":340,"wires":[["245a5d9a02f6bcb9","933933324462582d"]]},{"id":"3ce0d5f3cde9a512","type":"function","z":"33daa526a61fd4fe","name":"確認 刪除","func":"var del_id = flow.get(\"idtemp\");\n\n\nmsg.topic = \"DELETE FROM dhtreadings WHERE id= ($del_id) \" ;\nmsg.payload = [del_id]\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":260,"wires":[["9e04534fa30653d0"]]},{"id":"0817e2c6c9ca01c2","type":"ui_numeric","z":"33daa526a61fd4fe","name":"","label":"刪除的database_id","tooltip":"","group":"0c7dcb8629852c78","order":3,"width":4,"height":1,"wrap":false,"passthru":true,"topic":"topic","topicType":"msg","format":"{{value}}","min":"1","max":"1000","step":1,"className":"","x":110,"y":340,"wires":[["8b31d0247712f507"]]},{"id":"9e04534fa30653d0","type":"sqlite","z":"33daa526a61fd4fe","mydb":"dd7f8134e015a1cb","sqlquery":"msg.topic","sql":"DELETE FROM dhtreadings WHERE id =  VALUES ($theid)","name":"My_sensor","x":570,"y":260,"wires":[["54cdd2a0d639323a","c81728395a38ee81"]]},{"id":"54cdd2a0d639323a","type":"debug","z":"33daa526a61fd4fe","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":260,"wires":[]},{"id":"f23875ca03ba6bbe","type":"ui_button","z":"33daa526a61fd4fe","name":"","group":"0c7dcb8629852c78","order":6,"width":4,"height":1,"passthru":false,"label":"刪除一筆資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":100,"y":260,"wires":[["e4625c022eba764f"]]},{"id":"933933324462582d","type":"debug","z":"33daa526a61fd4fe","name":"debug 167","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":540,"y":300,"wires":[]},{"id":"096fac8ece986cd4","type":"ui_numeric","z":"33daa526a61fd4fe","name":"","label":"修改的database_id","tooltip":"","group":"0c7dcb8629852c78","order":4,"width":4,"height":1,"wrap":false,"passthru":true,"topic":"topic","topicType":"msg","format":"{{value}}","min":"1","max":"100","step":1,"className":"","x":170,"y":460,"wires":[["2dcb4bf0476fd926"]]},{"id":"94a3eeba03b0e0d8","type":"sqlite","z":"33daa526a61fd4fe","mydb":"dd7f8134e015a1cb","sqlquery":"msg.topic","sql":"","name":"My_sensor","x":490,"y":840,"wires":[["5efb323edd237abf","c5f6577f292c0eab"]]},{"id":"5efb323edd237abf","type":"debug","z":"33daa526a61fd4fe","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":840,"wires":[]},{"id":"09c1e39ea06d89fd","type":"ui_text_input","z":"33daa526a61fd4fe","name":"","label":"修改-Temperature","tooltip":"","group":"0c7dcb8629852c78","order":13,"width":3,"height":1,"passthru":true,"mode":"text","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":170,"y":600,"wires":[["7dcb34bd4e3bb33f"]]},{"id":"b71953d288275c20","type":"ui_text_input","z":"33daa526a61fd4fe","name":"","label":"修改-Humidity","tooltip":"","group":"0c7dcb8629852c78","order":14,"width":3,"height":1,"passthru":true,"mode":"text","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":160,"y":640,"wires":[["5d6e2ca1867b3a8f"]]},{"id":"126513b956c75409","type":"ui_text_input","z":"33daa526a61fd4fe","name":"","label":"修改-Date","tooltip":"","group":"0c7dcb8629852c78","order":15,"width":3,"height":1,"passthru":true,"mode":"text","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":140,"y":680,"wires":[["a0044bd62465b12a"]]},{"id":"252d42fe0135bd12","type":"ui_text_input","z":"33daa526a61fd4fe","name":"","label":"修改-Time","tooltip":"","group":"0c7dcb8629852c78","order":16,"width":3,"height":1,"passthru":true,"mode":"text","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":140,"y":720,"wires":[["5c41a88be11ce781"]]},{"id":"60019ad72601ec93","type":"ui_text_input","z":"33daa526a61fd4fe","name":"","label":"修改-Device","tooltip":"","group":"0c7dcb8629852c78","order":17,"width":3,"height":1,"passthru":true,"mode":"text","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":150,"y":760,"wires":[["8037bc801ec1fcac"]]},{"id":"2dcb4bf0476fd926","type":"function","z":"33daa526a61fd4fe","name":"STORE 更新參數 id","func":"var update_temp=msg.payload;\nflow.set(\"update_id\", update_temp);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":460,"wires":[["f62b8189e98a61d1","26aa09c1348370d8"]]},{"id":"7dcb34bd4e3bb33f","type":"function","z":"33daa526a61fd4fe","name":"STORE 更新參數 temperature","func":"var update_temp=msg.payload;\nflow.set(\"update_temperature\", update_temp);\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":600,"wires":[["cccdae928b68daf7"]]},{"id":"5d6e2ca1867b3a8f","type":"function","z":"33daa526a61fd4fe","name":"STORE 更新參數 humidity","func":"var update_temp=msg.payload;\nflow.set(\"update_humidity\", update_temp);","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":640,"wires":[["f13be9d04b1c4e4f"]]},{"id":"a0044bd62465b12a","type":"function","z":"33daa526a61fd4fe","name":"STORE 更新參數 currentdate","func":"var update_temp=msg.payload;\nflow.set(\"update_date\", update_temp);\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":680,"wires":[["23b655dbe34d3055"]]},{"id":"5c41a88be11ce781","type":"function","z":"33daa526a61fd4fe","name":"STORE 更新參數 currenttime","func":"var update_temp=msg.payload;\nflow.set(\"update_time\", update_temp);\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":720,"wires":[["f561bf6145779cfe"]]},{"id":"8037bc801ec1fcac","type":"function","z":"33daa526a61fd4fe","name":"STORE 更新參數 device","func":"var update_temp=msg.payload;\nflow.set(\"update_device\", update_temp);\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":390,"y":760,"wires":[["e768738424031078"]]},{"id":"7641852347d26cab","type":"ui_button","z":"33daa526a61fd4fe","name":"","group":"0c7dcb8629852c78","order":7,"width":4,"height":1,"passthru":false,"label":"更新update","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":150,"y":800,"wires":[["941d95621bd441e0","d83a5ef9b3e854d3"]]},{"id":"941d95621bd441e0","type":"function","z":"33daa526a61fd4fe","name":"確認 更新update","func":"var id = flow.get(\"update_id\");\nvar temperature = flow.get(\"update_temperature\");\nvar humidity = flow.get(\"update_humidity\");\nvar date = flow.get(\"update_date\");\nvar time = flow.get(\"update_time\");\nvar device = flow.get(\"update_device\");\n\n\nmsg.topic = \"UPDATE dhtreadings SET temperature=($temperature) ,humidity =($humidity) , currentdate = ($date) , currenttime = ($time), device = ($device) WHERE id is ($id) \" ;\nmsg.payload = [temperature,humidity,date,time,device , id ];\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":840,"wires":[["94a3eeba03b0e0d8"]]},{"id":"f62b8189e98a61d1","type":"debug","z":"33daa526a61fd4fe","name":"debug 168","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":460,"wires":[]},{"id":"cccdae928b68daf7","type":"debug","z":"33daa526a61fd4fe","name":"debug 169","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":580,"wires":[]},{"id":"f13be9d04b1c4e4f","type":"debug","z":"33daa526a61fd4fe","name":"debug 170","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":620,"y":640,"wires":[]},{"id":"23b655dbe34d3055","type":"debug","z":"33daa526a61fd4fe","name":"debug 171","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":620,"y":680,"wires":[]},{"id":"f561bf6145779cfe","type":"debug","z":"33daa526a61fd4fe","name":"debug 172","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":620,"y":720,"wires":[]},{"id":"e768738424031078","type":"debug","z":"33daa526a61fd4fe","name":"debug 173","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":620,"y":760,"wires":[]},{"id":"d83a5ef9b3e854d3","type":"delay","z":"33daa526a61fd4fe","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":320,"y":800,"wires":[["c87f9cc04aa03fc1"]]},{"id":"26967a922bc08b50","type":"ui_table","z":"33daa526a61fd4fe","group":"0c7dcb8629852c78","name":"","order":18,"width":15,"height":10,"columns":[],"outputs":0,"cts":false,"x":770,"y":200,"wires":[]},{"id":"a026414f7016385e","type":"inject","z":"33daa526a61fd4fe","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"1","payloadType":"num","x":90,"y":40,"wires":[["756402ca61060d4e"]]},{"id":"10ef26a70be2fcfb","type":"link in","z":"33daa526a61fd4fe","name":"link in 22","links":["f9df45643cf72a4c","c87f9cc04aa03fc1"],"x":235,"y":220,"wires":[["c81728395a38ee81"]]},{"id":"c5f6577f292c0eab","type":"link out","z":"33daa526a61fd4fe","name":"link out 22","mode":"link","links":["a2935491b290f24e"],"x":615,"y":800,"wires":[]},{"id":"663cea2aa3a41817","type":"sqlite","z":"33daa526a61fd4fe","mydb":"dd7f8134e015a1cb","sqlquery":"msg.topic","sql":"","name":"My_sensor","x":610,"y":420,"wires":[["ad11bd414726153a","f9df45643cf72a4c"]]},{"id":"f9df45643cf72a4c","type":"link out","z":"33daa526a61fd4fe","name":"link out 23","mode":"link","links":["10ef26a70be2fcfb"],"x":745,"y":420,"wires":[]},{"id":"e4625c022eba764f","type":"ui_toast","z":"33daa526a61fd4fe","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":270,"y":260,"wires":[["3ce0d5f3cde9a512"]]},{"id":"4f752e3354523649","type":"ui_toast","z":"33daa526a61fd4fe","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":250,"y":380,"wires":[["f2ba2da74f704218"]]},{"id":"b3a96681d913be03","type":"ui_toast","z":"33daa526a61fd4fe","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":270,"y":420,"wires":[["7ba37854c55531c4"]]},{"id":"756402ca61060d4e","type":"link out","z":"33daa526a61fd4fe","name":"link out 24","mode":"link","links":["5f6e87dbed1f5093"],"x":195,"y":40,"wires":[]},{"id":"5f6e87dbed1f5093","type":"link in","z":"33daa526a61fd4fe","name":"link in 23","links":["756402ca61060d4e"],"x":75,"y":300,"wires":[["0817e2c6c9ca01c2","096fac8ece986cd4"]]},{"id":"14ee7e7b9c3453fa","type":"function","z":"33daa526a61fd4fe","name":"function 74","func":"//CREATE TABLE dhtreadings(id INTEGER PRIMARY KEY AUTOINCREMENT,\n//temperature NUMERIC, \n//humidity NUMERIC, \n//currentdate DATE, \n//currenttime TIME,\n//device TEXT)\nvar update_temp=flow.get(\"update_id\");\nmsg.topic =  \"SELECT temperature,humidity,currentdate,currenttime,device FROM dhtreadings WHERE id LIKE ($update_temp)\" ; \nmsg.payload = [update_temp ];\nreturn msg;\n\n//SELECT\n//\ttrackid,\n//\tname\t\n//FROM\n//\ttracks\n//WHERE\n//\tname LIKE '%Wild%';","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":270,"y":880,"wires":[["55625ff6252c2662"]]},{"id":"626ba55e2438764f","type":"debug","z":"33daa526a61fd4fe","name":"debug 175","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":200,"wires":[]},{"id":"68bc303e3e64908e","type":"debug","z":"33daa526a61fd4fe","name":"debug 176","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":940,"wires":[]},{"id":"55625ff6252c2662","type":"sqlite","z":"33daa526a61fd4fe","mydb":"dd7f8134e015a1cb","sqlquery":"msg.topic","sql":"","name":"My_sensor","x":450,"y":880,"wires":[["48f967b3da0d3c6c","6d5cadd3285d5560"]]},{"id":"48f967b3da0d3c6c","type":"function","z":"33daa526a61fd4fe","name":"function 75","func":"var newMsg = { payload: msg.payload,topic:msg.topic };\nreturn newMsg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":940,"wires":[["68bc303e3e64908e","e8bf96702627235e"]]},{"id":"6d5cadd3285d5560","type":"debug","z":"33daa526a61fd4fe","name":"debug 177","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":880,"wires":[]},{"id":"e8bf96702627235e","type":"function","z":"33daa526a61fd4fe","name":"function 76","func":"var temperature=msg.payload[0].temperature;\nvar humidity=msg.payload[0].humidity;\nvar currentdate=msg.payload[0].currentdate;\nvar currenttime=msg.payload[0].currenttime;\nvar device=msg.payload[0].device;\n\nflow.set(\"update_temperature\", temperature);\nflow.set(\"update_humidity\",  humidity);\nflow.set(\"update_date\", currentdate);\nflow.set(\"update_time\", currenttime);\nflow.set(\"update_device\", device);\n\n\n\nmsg.payload=[temperature ,humidity , currentdate ,currenttime , device];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":1080,"wires":[["6d5cc36e1f1ed925","b4904edf99b6b57b","c776e614e75f1797","725dacf071d5a214","39ad5f015ea75d68"]]},{"id":"26aa09c1348370d8","type":"link out","z":"33daa526a61fd4fe","name":"link out 25","mode":"link","links":["16441c5a1f5e8906"],"x":525,"y":500,"wires":[]},{"id":"16441c5a1f5e8906","type":"link in","z":"33daa526a61fd4fe","name":"link in 24","links":["26aa09c1348370d8"],"x":125,"y":880,"wires":[["14ee7e7b9c3453fa"]]},{"id":"6d5cc36e1f1ed925","type":"function","z":"33daa526a61fd4fe","name":"get temperature","func":"msg.payload=flow.get(\"update_temperature\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":1000,"wires":[["1cbd126e307baaab"]]},{"id":"b4904edf99b6b57b","type":"function","z":"33daa526a61fd4fe","name":"get humidity","func":"msg.payload=flow.get(\"update_humidity\");\nreturn msg;\n\n//flow.set(\"update_temperature\", temperature);\n//flow.set(\"update_humidity\",  humidity);\n//flow.set(\"update_date\", currentdate);\n//flow.set(\"update_time\", currenttime);\n//flow.set(\"update_device\", device);\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":670,"y":1040,"wires":[["20a11e565df3a276"]]},{"id":"c776e614e75f1797","type":"function","z":"33daa526a61fd4fe","name":"get date","func":"msg.payload=flow.get(\"update_date\");\nreturn msg;\n\n//flow.set(\"update_temperature\", temperature);\n//flow.set(\"update_humidity\",  humidity);\n//flow.set(\"update_date\", currentdate);\n//flow.set(\"update_time\", currenttime);\n//flow.set(\"update_device\", device);\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":1080,"wires":[["ac3394f988211f0d"]]},{"id":"725dacf071d5a214","type":"function","z":"33daa526a61fd4fe","name":"get time","func":"msg.payload=flow.get(\"update_time\");\nreturn msg;\n\n//flow.set(\"update_temperature\", temperature);\n//flow.set(\"update_humidity\",  humidity);\n//flow.set(\"update_date\", currentdate);\n//flow.set(\"update_time\", currenttime);\n//flow.set(\"update_device\", device);\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":1120,"wires":[["723e99e3ab6e76f8"]]},{"id":"39ad5f015ea75d68","type":"function","z":"33daa526a61fd4fe","name":"get device","func":"msg.payload=flow.get(\"update_device\");\nreturn msg;\n\n\n//flow.set(\"update_temperature\", temperature);\n//flow.set(\"update_humidity\",  humidity);\n//flow.set(\"update_date\", currentdate);\n//flow.set(\"update_time\", currenttime);\n//flow.set(\"update_device\", device);","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":670,"y":1160,"wires":[["763a2cfa98bda080"]]},{"id":"9139f0efdbae4ff6","type":"link in","z":"33daa526a61fd4fe","name":"link in 25","links":["1cbd126e307baaab"],"x":25,"y":600,"wires":[["09c1e39ea06d89fd"]]},{"id":"1cbd126e307baaab","type":"link out","z":"33daa526a61fd4fe","name":"link out 26","mode":"link","links":["9139f0efdbae4ff6"],"x":795,"y":1000,"wires":[]},{"id":"8ca561893844765b","type":"link in","z":"33daa526a61fd4fe","name":"link in 26","links":["20a11e565df3a276"],"x":25,"y":640,"wires":[["b71953d288275c20"]]},{"id":"20a11e565df3a276","type":"link out","z":"33daa526a61fd4fe","name":"link out 27","mode":"link","links":["8ca561893844765b"],"x":795,"y":1040,"wires":[]},{"id":"e0819cf5d59119e6","type":"link in","z":"33daa526a61fd4fe","name":"link in 27","links":["ac3394f988211f0d"],"x":25,"y":680,"wires":[["126513b956c75409"]]},{"id":"ac3394f988211f0d","type":"link out","z":"33daa526a61fd4fe","name":"link out 28","mode":"link","links":["e0819cf5d59119e6"],"x":795,"y":1080,"wires":[]},{"id":"6b56170b0abe6acb","type":"link in","z":"33daa526a61fd4fe","name":"link in 28","links":["723e99e3ab6e76f8"],"x":25,"y":720,"wires":[["252d42fe0135bd12"]]},{"id":"723e99e3ab6e76f8","type":"link out","z":"33daa526a61fd4fe","name":"link out 29","mode":"link","links":["6b56170b0abe6acb"],"x":795,"y":1120,"wires":[]},{"id":"e7a08b8bce55ff7c","type":"link in","z":"33daa526a61fd4fe","name":"link in 29","links":["763a2cfa98bda080"],"x":25,"y":760,"wires":[["60019ad72601ec93"]]},{"id":"763a2cfa98bda080","type":"link out","z":"33daa526a61fd4fe","name":"link out 30","mode":"link","links":["e7a08b8bce55ff7c"],"x":785,"y":1160,"wires":[]},{"id":"c87f9cc04aa03fc1","type":"link out","z":"33daa526a61fd4fe","name":"link out 31","mode":"link","links":["10ef26a70be2fcfb"],"x":435,"y":800,"wires":[]},{"id":"0c7dcb8629852c78","type":"ui_group","name":"Default","tab":"135f4ab98c2d8190","order":1,"disp":true,"width":"15","collapse":false,"className":""},{"id":"dd7f8134e015a1cb","type":"sqlitedb","db":"C:\\Users\\User\\.node-red\\my_2023weather.db","mode":"RWC"},{"id":"135f4ab98c2d8190","type":"ui_tab","name":"SQLite_Database","icon":"dashboard","disabled":false,"hidden":false}]

沒有留言:

張貼留言

2024_09 作業3 以Node-Red 為主

 2024_09 作業3  (以Node-Red 為主  Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker  2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...