3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

MQTTを使ってInfluxDBで記録とダッシュボード表示しつつ、他のデバイスにも送るメモ

Last updated at Posted at 2021-10-17

はじめに

前のはMQTTの本来の持ち味が生かせておらず、通信経路としてだけだったので、同報通知するパータンをメモする。

InfluxDB(時系列DB)

を参考に設定と実行を

InfluxDB側でMQTTを使うわけではないのでTelegrafは不要

image.png

M5Stack(送信側)

こんな感じでJson形式で送信
image.png

Node-RED

1つ目のフロー(MQTT Broker)

こんな感じ
image.png

参考

2つ目のフロー

準備

パレットで、node-red-contrib-influxdbをインストールします。
image.png

ストレージにInfluxDB関係がインストールされました。
image.png

MQTT IN

MQTT IN はこんな感じ
image.png

InfluxDB

influxdbは”influxdb out”でも"influxdb batch"でも出来そう。ここでは"influxdn out"を使ってみる。

image.png
名前はInfluxDBにして、Serverは右の鉛筆をクリックするとノード編集になるから各値を入れる。
image.png
追加して、Influxdb outのプロパティが(サーバのVerifyが終わったら?)少し項目が変わるので、続けて入力
image.png

Functionノード

Functionノードをおいて
image.png

結合

あとは結んで
image.png

確認

InfluxDBのデータExplorerで確認
image.png

2つ目のM5Stack(受信側)

こんな感じでJson形式で受信したものの温度だけ表示
image.png

結果

M5StickC+の方を警報灯にしたりできるから、実運用はこの形もありだと思います。
image.png

3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?