2021年1月22日 星期五

Node-Red & MQTT & Dashboard UI & MQTT Explorer

 Node-Red & MQTT &Dashboard UI &MQTT Explorer

http://mqtt-explorer.com/



Function 設定

var led=msg.payload;

if (led==='ON'){

    msg.payload=true;

}

else

{

    msg.payload=false;

}

return msg;










[{"id":"5a45b8da.52b0d8","type":"mqtt in","z":"a14ac84e.f72398","name":"","topic":"alex9ufo/esp32/dht/temperature","qos":"1","datatype":"auto","broker":"e4d9b72d.d14398","x":190,"y":120,"wires":[["3042e15e.80a4ee"]]},{"id":"3042e15e.80a4ee","type":"ui_gauge","z":"a14ac84e.f72398","name":"","group":"ac0f1141.eb50e","order":2,"width":"3","height":"2","gtype":"gage","title":"Temperature","label":"ºC","format":"{{value}}","min":0,"max":"40","colors":["#00b500","#f7df09","#ca3838"],"seg1":"","seg2":"","x":450,"y":120,"wires":[]},{"id":"8ff168f0.0c74a8","type":"mqtt in","z":"a14ac84e.f72398","name":"","topic":"alex9ufo/esp32/dht/humidity","qos":"1","datatype":"auto","broker":"e4d9b72d.d14398","x":180,"y":180,"wires":[["29251f29.6687c"]]},{"id":"29251f29.6687c","type":"ui_gauge","z":"a14ac84e.f72398","name":"","group":"ac0f1141.eb50e","order":2,"width":"3","height":"2","gtype":"gage","title":"Humidity","label":"%","format":"{{value}}","min":"30","max":"100","colors":["#53a4e6","#1d78a9","#4e38c9"],"seg1":"","seg2":"","x":440,"y":180,"wires":[]},{"id":"76ff0708.6cfb98","type":"mqtt out","z":"a14ac84e.f72398","name":"","topic":"alex9ufo/esp32/dht/humidity","qos":"1","retain":"","broker":"e4d9b72d.d14398","x":520,"y":300,"wires":[]},{"id":"5595d22f.f517bc","type":"mqtt out","z":"a14ac84e.f72398","name":"","topic":"alex9ufo/esp32/dht/temperature","qos":"1","retain":"","broker":"e4d9b72d.d14398","x":530,"y":360,"wires":[]},{"id":"c7d10b69.439238","type":"function","z":"a14ac84e.f72398","name":"亂數10-100","func":"var min= 30;\nvar max= 100 ;\n\nmsg.payload = Math.floor(Math.random()*(max-min+1))+min;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":300,"wires":[["76ff0708.6cfb98"]]},{"id":"209f02c1.6c6a5e","type":"function","z":"a14ac84e.f72398","name":"10-40亂數","func":"var min= 10;\nvar max= 40 ;\n\nmsg.payload = Math.floor(Math.random()*(max-min+1))+min;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":360,"wires":[["5595d22f.f517bc"]]},{"id":"93cb2ee9.76dea","type":"inject","z":"a14ac84e.f72398","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"20","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":121,"y":300,"wires":[["c7d10b69.439238"]]},{"id":"4b88a9f2.6e2ff8","type":"inject","z":"a14ac84e.f72398","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"20","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":360,"wires":[["209f02c1.6c6a5e"]]},{"id":"a49f7111.8ad3b","type":"ui_button","z":"a14ac84e.f72398","name":"","group":"ac0f1141.eb50e","order":0,"width":"2","height":"1","passthru":false,"label":"LED 開","tooltip":"","color":"white","bgcolor":" purple","icon":"fa-circle","payload":"ON","payloadType":"str","topic":"","x":120,"y":420,"wires":[["d225a53d.306a38"]]},{"id":"e83bb5b4.b33b88","type":"ui_button","z":"a14ac84e.f72398","name":"","group":"ac0f1141.eb50e","order":0,"width":"2","height":"1","passthru":false,"label":"LED 關","tooltip":"","color":"black","bgcolor":"","icon":"fa-circle-o","payload":"OFF","payloadType":"str","topic":"","x":120,"y":460,"wires":[["d225a53d.306a38"]]},{"id":"d225a53d.306a38","type":"mqtt out","z":"a14ac84e.f72398","name":"","topic":"alex9ufo/inTopic/led/led_event","qos":"1","retain":"true","broker":"841df58d.ee5e98","x":350,"y":440,"wires":[]},{"id":"1c937d70.b216f3","type":"mqtt in","z":"a14ac84e.f72398","name":"","topic":"alex9ufo/inTopic/led/led_event","qos":"2","datatype":"auto","broker":"e4d9b72d.d14398","x":180,"y":240,"wires":[["1d351370.11523d"]]},{"id":"3870456d.2a0f9a","type":"ui_led","z":"a14ac84e.f72398","group":"ac0f1141.eb50e","order":68,"width":"0","height":"0","label":"LED Status","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"green","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"","x":490,"y":240,"wires":[]},{"id":"1d351370.11523d","type":"function","z":"a14ac84e.f72398","name":"","func":"var led=msg.payload;\nif (led==='ON'){\n    msg.payload=true;\n}\nelse\n{\n    msg.payload=false;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":240,"wires":[["3870456d.2a0f9a"]]},{"id":"e4d9b72d.d14398","type":"mqtt-broker","name":"","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"ac0f1141.eb50e","type":"ui_group","name":"LED","tab":"834e019a.2dfbb","order":1,"disp":true,"width":"8","collapse":true},{"id":"841df58d.ee5e98","type":"mqtt-broker","name":"","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"834e019a.2dfbb","type":"ui_tab","name":"MongoDB","icon":"dashboard","disabled":false,"hidden":false}]

2021年1月11日 星期一

MQTTool – MQTT for iPhone

 MQTTool – MQTT for iPhone

源自於 https://leeluchowdaryravi.wordpress.com/2018/02/26/node-red-sensors-store-data-in-mongodb-database-and-exploring-thingspeak-mqttool/

Although in the examples I have given above I used PC based software to carryout my testing, equally it is possible to use a smartphone app. So, This is an MQTT client and test tool.

IMG_3481

IMG_3480

I have Installed the application via Appstore on iPhoneX. Opened the application and made the  following changes.

  • Enter host the shared network of Mac (IPV4 address) and the default port 1883.
  • Click on connect

1520880523987

  • It is connected to the port and next click on Subscribe
  • Enter the Topic as per the code and like we did above for Node-Red /devices/”device_id”/events in my case
  • Make the QOS to 2 and click Subscribe
  • You will see that it is Subscribed to the topic

IMG_3479

  • Click on Publish and enter the Topic & Message like we did above. Retain and Publish

IMG_3477

  • Hit on Stats to see the details

1520880470026

  • Here we see the values from DTH22 sensor flowing in our phone. Isn’t it simple and useful to see the activities remotely using your cell phone. All that we did is to setup the device using Mongoose-OS keep it connected to our mobile app using MQTT broker on local network.

IMG_1990

 

Node-Red MongoDB

 Node-Red MongoDB 

參考來源

https://leeluchowdaryravi.wordpress.com/2018/02/26/node-red-sensors-store-data-in-mongodb-database-and-exploring-thingspeak-mqttool/

MongoDB與Studio 3T 儲存檔案位置

http://alex9ufoexploer.blogspot.com/2018/11/mongodb-studio-3t.html







UI ON,OFF 按鈕輸出 ON ,OFF payload 發行到到MQTT broker.mqtt-dashboard.com : 1883

Topic 為 alex9ufo/mongodb/LED

訂閱 Topic : alex9ufo/mongodb/LED 主題送至MongodB  儲存到 D:\Mongodb\data目錄下

MongoDbIOT 伺服器 Collections 為IOT 



1)啟動Mongodb  安裝目錄為 D:\Mongodb

a.bat 批次檔

d:

cd D:\Mongodb\bin

mongod --dbpath d:\MongoDB\data\db


2) Studio 3T 使用 Studio 3T 作為管理 MongoDB 的方法



Connect 將Studio3T 與MongoDB連上



建立 資料庫檔MongoDbIOT 需與 Node-Red mongodb 節點的 檔名相同



與Nongodb節點的 Database 檔名 相同 Collections :IOT 也要相同
並且建立Username 與Password 














最新10筆資料function 

msg.limit = 10;

msg.skip = 0;

msg.sort = {"_id": -1}

return msg;


Json的內容 "_id", "payload"  二個欄位

    "_id" : ObjectId("5ffad9eda72c080c0421ba8d"), 

    "payload" : "OFF"

}


MongoDB節點設定

1) Save 儲存紀錄(record)


2) Find 查詢紀錄(record)

 


Node-Red 程式

[{"id":"e644df1.2a90c2","type":"mqtt out","z":"27b256ba.2bff8a","name":"MongoLED","topic":"alex9ufo/mongodb/LED","qos":"1","retain":"","broker":"e4d9b72d.d14398","x":250,"y":60,"wires":[]},{"id":"ce5e629e.b0ec3","type":"mqtt in","z":"27b256ba.2bff8a","name":"MongoLED","topic":"alex9ufo/mongodb/LED","qos":"1","datatype":"auto","broker":"e4d9b72d.d14398","x":100,"y":140,"wires":[["99c257df.71e118","c8b5e7f0.6c4d58"]]},{"id":"99c257df.71e118","type":"ui_text","z":"27b256ba.2bff8a","group":"ac0f1141.eb50e","order":63,"width":"0","height":"0","name":"","label":"LED Status","format":"{{msg.payload}}","layout":"row-center","x":270,"y":200,"wires":[]},{"id":"300cba7b.f67f86","type":"ui_button","z":"27b256ba.2bff8a","name":"","group":"ac0f1141.eb50e","order":61,"width":"0","height":"0","passthru":false,"label":"ON","tooltip":"","color":"","bgcolor":"","icon":"","payload":"ON","payloadType":"str","topic":"","x":90,"y":40,"wires":[["e644df1.2a90c2"]]},{"id":"dcb72cf1.f01c5","type":"ui_button","z":"27b256ba.2bff8a","name":"","group":"ac0f1141.eb50e","order":62,"width":"0","height":"0","passthru":false,"label":"OFF","tooltip":"","color":"","bgcolor":"","icon":"","payload":"OFF","payloadType":"str","topic":"","x":90,"y":100,"wires":[["e644df1.2a90c2"]]},{"id":"c8b5e7f0.6c4d58","type":"mongodb out","z":"27b256ba.2bff8a","mongodb":"7faa7c87.42e514","name":"","collection":"IOT","payonly":true,"upsert":false,"multi":false,"operation":"store","x":340,"y":140,"wires":[]},{"id":"76030ade.7f7e44","type":"mongodb in","z":"27b256ba.2bff8a","mongodb":"7faa7c87.42e514","name":"","collection":"IOT","operation":"find","x":220,"y":300,"wires":[["68a9fd33.b402d4","4cdc7aff.a11b94"]]},{"id":"68a9fd33.b402d4","type":"debug","z":"27b256ba.2bff8a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":360,"wires":[]},{"id":"3c744d.2d382bb4","type":"function","z":"27b256ba.2bff8a","name":"最新5筆資料","func":"msg.limit = 10;\nmsg.skip = 0;\nmsg.sort = {\"_id\": -1}\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":310,"y":240,"wires":[["76030ade.7f7e44"]]},{"id":"3f02bea7.f78692","type":"ui_button","z":"27b256ba.2bff8a","name":"","group":"ac0f1141.eb50e","order":65,"width":0,"height":0,"passthru":false,"label":"檢視最新10筆資料","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":130,"y":240,"wires":[["3c744d.2d382bb4"]]},{"id":"4cdc7aff.a11b94","type":"ui_table","z":"27b256ba.2bff8a","group":"ac0f1141.eb50e","name":"","order":65,"width":0,"height":0,"columns":[],"outputs":0,"cts":false,"x":490,"y":300,"wires":[]},{"id":"e4d9b72d.d14398","type":"mqtt-broker","name":"","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"ac0f1141.eb50e","type":"ui_group","name":"LED","tab":"834e019a.2dfbb","order":1,"disp":true,"width":"8","collapse":true},{"id":"7faa7c87.42e514","type":"mongodb","hostname":"127.0.0.1","port":"27017","db":"MongoDbIOT","name":""},{"id":"834e019a.2dfbb","type":"ui_tab","name":"MongoDB","icon":"dashboard","disabled":false,"hidden":false}]

2021年1月7日 星期四

安裝 api-ms-win-crt-runtime-l1-1-0.dll檔案

 

安裝 api-ms-win-crt-runtime-l1-1-0.dll檔案

75218軟體

    1. 下載 KB2999226

        以 Windows 7 64位元為例,下載的檔案為 Windows6.1-KB2999226-x64.msu(儲存在 C:\DOWNLOAD目錄下)

    以系統管理員身分執行『命令提示字元』,以下指令都在『命令提示字元』底下執行
    2. 由於 wusa.exe與 DISM.exe兩支程式都放在 C:\Windows\System32 目錄下
         透過 cd指令切換至 C:\Windows\System32 目錄

         cd\windows\system32

    3. 透過 wusa.exe對 msu檔案解壓至 c:\test目錄下

        wusa.exe C:\DOWNLOAD\Windows6.1-KB2999226-x64.msu /extract:c:\test

    4. 將存在 c:\test目錄下的 Windows6.1-KB2999226-x64.cab檔,透過 DISM.exe程式來安裝 KB2999226

        DISM.exe /Online /Add-Package /PackagePath:c:\test\Windows6.1-KB2999226-x64.cab


    參考資料:https://blog.xuite.net/sugopili/computerblog/459059218-%E5%AE%89%E8%A3%9D+api-ms-win-crt-runtime-l1-1-0.dll%E6%AA%94%E6%A1%88

    Node-Red與 Sqlite

     Node-Red與 Sqlite 

    參考來源 https://funprojects.blog/2019/12/26/sqlite-and-node-red/

    1) 安裝SQLite 

    https://flows.nodered.org/node/node-red-node-sqlite .

    節點管理



    2. 產生一個資料庫與資料表Table

    下載 DB Browser for SQLite  https://sqlitebrowser.org/dl/

    產生一個資料庫名稱sqlite_0.db  資料表 temps

    並將資料庫copy 到目錄 C:\Users\{使用者alex}\AppData\Roaming\npm 下

    (AppData\Roaming須將隱藏目錄開啟)












      產生一個資料庫與資料表Table的另一方式 

     例如 資料庫名稱 sqlte_1.db , 資料表Table為temp_table 

     直接由function 產生

    msg.topic = ' CREATE TABLE "temp_table" ("thetime" Timestamp,"thetemp" integer)';

    return msg;




    到目錄C:\Users\{使用者alex}\AppData\Roaming\npm 下檢視






    CREATE TABLE "temp_table" ("thetime" Timestamp,"thetemp" integer)

    此為 function的內容

    3. 插入一筆記錄 record到資料庫內

    function內容

    // Create a Params variable

    // with a time and value component

    //

    msg.params = { $thetime:Date.now(), $thevalue:msg.payload }

    return msg;


    SQLite 設定


    insert into temp_table (thetime,thetemp) values ($thetime,$thevalue);

    4. 查詢資料庫的內容

    按一下 時間戳 即可 插入一筆記錄到資料庫 可以使用 DB Browser檢視


    另一種 查詢方式

    function內容

    msg.topic ='select * from temp_table';

    return msg;




    5.自定義折線圖
    function內容
    msg.payload = [{
    "series": ["A"],
    "data": [
    [{ "x": 1577229315152, "y": 5 },
    { "x": 1577229487133, "y": 4 },
    { "x": 1577232484872, "y": 6 }
    ]
    ],
    "labels": ["Data Values"]
    }];
     return msg;        
                              

    6.折線圖中的Sqlite數據
    SQL select statement function內容

    msg.topic = 'select * from temp_table LIMIT 8 OFFSET (SELECT COUNT(*) FROM temp_table)-8';
    return msg;

    format for the Line Char function內容
     //  
     // Create a data variable   
     //  
     var series = ["temp DegC"];  
     var labels = ["Data Values"];  
     var data = "[[";  
       
     for (var i=0; i < msg.payload.length; i++) {  
       data += '{ "x":' + msg.payload[i].thetime + ', "y":' + msg.payload[i].thetemp + '}';  
       if (i < (msg.payload.length - 1)) {  
         data += ","  
       } else {  
         data += "]]"  
       }  
     }  
     var jsondata = JSON.parse(data);  
     msg.payload = [{"series": series, "data": jsondata, "labels": labels}];  
       
     return msg;  



    Node-Red程式
    [{"id":"e22f5e71.9cbba","type":"inject","z":"4b313a3e.f07594","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":100,"wires":[["cf154dfc.2903e"]]},{"id":"e3f04b63.a39198","type":"sqlite","z":"4b313a3e.f07594","mydb":"19f59ce9.3edc23","sqlquery":"msg.topic","sql":"","name":"SQLite_1","x":520,"y":100,"wires":[[]]},{"id":"cf154dfc.2903e","type":"function","z":"4b313a3e.f07594","name":"產生資料庫TABLE","func":"msg.topic = ' CREATE TABLE \"temp_table\" (\"thetime\" Timestamp,\"thetemp\" integer)';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":310,"y":100,"wires":[["e3f04b63.a39198"]]},{"id":"5dd7a32f.947adc","type":"inject","z":"4b313a3e.f07594","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"2","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":200,"wires":[["fd4dcd3e.0e2fc"]]},{"id":"fd4dcd3e.0e2fc","type":"random","z":"4b313a3e.f07594","name":"","low":1,"high":10,"inte":"true","property":"payload","x":280,"y":200,"wires":[["a3c6dc15.43244"]]},{"id":"6a4dca3c.b7e704","type":"sqlite","z":"4b313a3e.f07594","mydb":"19f59ce9.3edc23","sqlquery":"prepared","sql":"insert into temp_table (thetime,thetemp) values ($thetime,$thevalue);\n","name":"","x":470,"y":240,"wires":[["df17d29e.105b5"]]},{"id":"df17d29e.105b5","type":"debug","z":"4b313a3e.f07594","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":240,"wires":[]},{"id":"a3c6dc15.43244","type":"function","z":"4b313a3e.f07594","name":"","func":"// Create a Params variable\n// with a time and value component\n//\nmsg.params = { $thetime:Date.now(), $thevalue:msg.payload }\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":450,"y":200,"wires":[["6a4dca3c.b7e704","d83b830d.13f44"]]},{"id":"d83b830d.13f44","type":"debug","z":"4b313a3e.f07594","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":180,"wires":[]},{"id":"84c0e643.ac8ca8","type":"inject","z":"4b313a3e.f07594","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":320,"wires":[["44fed989.edfb68"]]},{"id":"44fed989.edfb68","type":"function","z":"4b313a3e.f07594","name":"","func":"msg.topic ='select * from temp_table';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":320,"wires":[["58a6c538.f62bdc"]]},{"id":"58a6c538.f62bdc","type":"sqlite","z":"4b313a3e.f07594","mydb":"19f59ce9.3edc23","sqlquery":"msg.topic","sql":"","name":"SQLite_1","x":460,"y":320,"wires":[["6a74d365.f0666c"]]},{"id":"6a74d365.f0666c","type":"debug","z":"4b313a3e.f07594","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":320,"wires":[]},{"id":"bf03d5f2.bf1508","type":"ui_chart","z":"4b313a3e.f07594","name":"","group":"d5da3e9b.46abf","order":2,"width":0,"height":0,"label":"chart","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,"x":530,"y":400,"wires":[[]]},{"id":"753a0289.37d6fc","type":"inject","z":"4b313a3e.f07594","name":"1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":400,"wires":[["c0d2b7b6.380cb8"]]},{"id":"c0d2b7b6.380cb8","type":"function","z":"4b313a3e.f07594","name":"","func":"msg.payload = [{\n\"series\": [\"A\"],\n\"data\": [\n[{ \"x\": 1577229315152, \"y\": 5 },\n{ \"x\": 1577229487133, \"y\": 4 },\n{ \"x\": 1577232484872, \"y\": 6 }\n]\n],\n\"labels\": [\"Data Values\"]\n}];\n \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":400,"wires":[["bf03d5f2.bf1508"]]},{"id":"45c0675c.5a1e38","type":"inject","z":"4b313a3e.f07594","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"20","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":480,"wires":[["9ac8c84d.66b498"]]},{"id":"9ac8c84d.66b498","type":"function","z":"4b313a3e.f07594","name":"SQL select statement","func":"msg.topic = 'select * from temp_table LIMIT 8 OFFSET (SELECT COUNT(*) FROM temp_table)-8';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":480,"wires":[["9969c47e.b3f568"]]},{"id":"6a845511.aa0dbc","type":"function","z":"4b313a3e.f07594","name":"format for the Line Char","func":" //  \n // Create a data variable   \n //  \n var series = [\"temp DegC\"];  \n var labels = [\"Data Values\"];  \n var data = \"[[\";  \n   \n for (var i=0; i < msg.payload.length; i++) {  \n   data += '{ \"x\":' + msg.payload[i].thetime + ', \"y\":' + msg.payload[i].thetemp + '}';  \n   if (i < (msg.payload.length - 1)) {  \n     data += \",\"  \n   } else {  \n     data += \"]]\"  \n   }  \n }  \n var jsondata = JSON.parse(data);  \n msg.payload = [{\"series\": series, \"data\": jsondata, \"labels\": labels}];  \n   \n   \n return msg;  ","outputs":1,"noerr":0,"initialize":"","finalize":"","x":510,"y":560,"wires":[["dd96ec63.fdda1","bbde99b8.0ebf88"]]},{"id":"9969c47e.b3f568","type":"sqlite","z":"4b313a3e.f07594","mydb":"19f59ce9.3edc23","sqlquery":"msg.topic","sql":"","name":"SQLite_1","x":300,"y":560,"wires":[["6a845511.aa0dbc"]]},{"id":"dd96ec63.fdda1","type":"ui_chart","z":"4b313a3e.f07594","name":"","group":"d5da3e9b.46abf","order":2,"width":0,"height":0,"label":"SQLite Data","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,"x":710,"y":520,"wires":[[]]},{"id":"bbde99b8.0ebf88","type":"debug","z":"4b313a3e.f07594","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":580,"wires":[]},{"id":"19f59ce9.3edc23","type":"sqlitedb","db":"sqlite_1.db","mode":"RWC"},{"id":"d5da3e9b.46abf","type":"ui_group","name":"SQLite_1","tab":"d76149c6.626598","order":2,"disp":true,"width":"6","collapse":false},{"id":"d76149c6.626598","type":"ui_tab","name":"SQLite","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...