2019年11月30日 星期六

Node-RED SQLite產生資料庫 新增一筆 資料 讀取資料庫


The tutorial will cover the basics of:
  • Setting up the dblite (SQLite) node and creating a DB table
  • Generating random data and storing in the SQLite DB
  • Reading from the SQLite DB
  • Graphing the data from the DB using the standard Node-RED UI nodes



[{"id":"4d641f65.581ad","type":"comment","z":"58734155.f17b4","name":"","info":"CREATE TABLE dhtreadings(id INTEGER PRIMARY KEY AUTOINCREMENT, temperature NUMERIC, humidity NUMERIC, currentdate DATE, currenttime TIME, device TEXT)\n\nINSERT INTO dhtreadings(temperature, humidity, currentdate, currenttime, device) values(22.4, 48, date('now'), time('now'), \"manual\")\n\nSELECT * FROM dhtreadings\n","x":100,"y":460,"wires":[]},{"id":"30043f2c.ba265","type":"inject","z":"58734155.f17b4","name":"CREATE","topic":"CREATE TABLE dhtreadings(id INTEGER PRIMARY KEY AUTOINCREMENT, temperature NUMERIC, humidity NUMERIC, currentdate DATE, currenttime TIME, device TEXT)","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":520,"wires":[["a8a68516.7d69b8"]]},{"id":"13b1a3c6.fa9a1c","type":"inject","z":"58734155.f17b4","name":"INSERT","topic":"INSERT INTO dhtreadings(temperature, humidity, currentdate, currenttime, device) values(22.4, 48, date('now'), time('now'), \"manual\")","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":580,"wires":[["a8a68516.7d69b8"]]},{"id":"43ebb8db.077628","type":"inject","z":"58734155.f17b4","name":"View Records","topic":"SELECT * FROM dhtreadings","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":660,"wires":[["b0b9faea.c4bb38"]]},{"id":"86689a7b.795978","type":"debug","z":"58734155.f17b4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":490,"y":540,"wires":[]},{"id":"130e63c1.a5a27c","type":"ui_template","z":"58734155.f17b4","group":"b165cbf1.03d608","name":"UI Table","order":2,"width":"6","height":"3","format":"<table style=\"width:100%\">\n  <tr>\n    <th>Time</th> \n    <th>Temp</th> \n    <th>Hum</th>\n  </tr>\n  <tr ng-repeat=\"x in msg.payload | limitTo:120\">\n    <td>{{msg.payload[$index].currenttime}}</td>\n    <td>{{msg.payload[$index].temperature}}</td> \n    <td>{{msg.payload[$index].humidity}}</td>\n  </tr>\n</table>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":480,"y":640,"wires":[[]]},{"id":"b0b9faea.c4bb38","type":"sqlite","z":"58734155.f17b4","mydb":"af927aba.0dc108","sqlquery":"msg.topic","sql":"","name":"SQLite","x":310,"y":640,"wires":[["130e63c1.a5a27c"]]},{"id":"a8a68516.7d69b8","type":"sqlite","z":"58734155.f17b4","mydb":"af927aba.0dc108","sqlquery":"msg.topic","sql":"","name":"SQLite","x":310,"y":540,"wires":[["86689a7b.795978"]]},{"id":"b165cbf1.03d608","type":"ui_group","z":"","name":"Data","tab":"6946f4ef.f94eec","order":3,"disp":true,"width":"6","collapse":false},{"id":"af927aba.0dc108","type":"sqlitedb","z":"","db":"db_003.db","mode":"RWC"},{"id":"6946f4ef.f94eec","type":"ui_tab","z":"","name":"Sqlit_4","icon":"photo_camera","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...