#6 監測資料寫入InfluxDB資料庫, 長期保存並在NodeRED資訊看板裡顯示
大家好, 今天來和大家分享 “一起來學樹莓派, 寫入InfluxDB 資料庫”. 上集分享的是資料送到 MQTT 顯示到資訊看板後, 時間後後資料就消失了. 本集是把所有的資料收集起來之後, 可以用來以後做為資料分析的依據. 以前你可能要把資料寫到 Thinkspeak server上, 現在自己家裡的樹莓派上就可以做到了! 一起來學樹莓派吧! 這影片內容有: 安裝 InfluxDB 資料庫 比較 InfluxDB 與關聯式資庫的不同 如何把ESP32送到 MQTT 資料寫入InfluxDB 資料庫 讀取InfluxDB 資料庫, 再把這些資料在資訊看板上顯示出來 Format code for writing InfluxDB // Create the object key to match DB filed name from topic name(studio/temp1) msg.payload["temp"] = msg.payload["studio/temp1"]; // Delete the unwanted studio/temp1 delete msg.payload["studio/temp1"]; // Update temp from string to float msg.payload["temp"] = parseFloat(msg.payload["temp"]); msg.payload["humd"] = msg.payload["studio/humd1"]; delete msg.payload["studio/humd1"]; msg.payload["humd"] = parseFloat(msg.payload["humd"]); //remove unused topic delete msg.topic; //Create a temporary array var data = []; data.push(msg.payload); //Add object to DB Tag(in